Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

=+What do they (audience members) currently think?

Answered: 1 week ago