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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started