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.
This code is used:
const int SIZE = 10;
// PLACE ALL OF THIS PROGRAM'S prototypes and Declarations here, comment your code.
// PLACE CODE HERE FOR TASK A // *************************************************
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
std::cout << ", and there were " << repeaters << " repeats.";
cout << "end of task A" << endl; cin.get(); }
// PLACE CODE HERE FOR TASK A // ************************************************* // TASK A CODE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
