Question: IN C++ PROGRAMMING: We are going to write a program that is called deleteRepeats that is passed an array of characters and have the function

IN C++ PROGRAMMING:

We are going to write a program that is called deleteRepeats that is passed

an array of characters and have the function remove all the repeated

letters/numbers from the array. The array is passed but not the SIZE b/c it is

a global constant. The function returns a unique pointer.

Your function should determine if a letter repeated and, if so, that repeating

letter is deleted. The function should continue scanning the array for any

other repeats until it reaches the end of the array. The (non-repeat)

remaining letters/numbers will form the new array where the size will be

exactly

that of the remaining unique letters/numbers.

Your function should determine if a letter repeated in the next position of the

array and, if so, that letter is deleted. Then go to the next, etc. The non-

repeats or remaining letters/numbers will form the new dynamic array and

the size must be exactly that of the remaining unique letters. Do not create

the new array until you know the size. Do create the new array on the heap.

// PLACE ALL OF THIS PROGRAM'S prototypes and Declarations at the top, comment your code

This code is used:

void taskA() {

//int variable to hold number of corresponding elements short int repeaters = 0; //test array of chars char originalArray[SIZE]; originalArray [0] = 'a'; originalArray [1] = 'b'; originalArray [2] = 'b'; originalArray [3] = 'c'; originalArray [4] = 'a'; originalArray [5] = 'c'; originalArray [6] = 'a'; originalArray [7] = 'c'; originalArray [8] = 'b'; originalArray [9] = 'a'; //deleteRepeats function call, and stores returned pointer in noRepeats std::unique_ptr noRepeats = deleteRepeats(originalArray, repeaters); std::cout << "The new array is: " << std::endl; for (int i = 0; i < SIZE - repeaters; ++i) { std::cout << noRepeats[i] << " "; }

std::cout << ", and there were " << repeaters << " repeats.";

cout << "end of task A" << endl; cin.get(); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!