This is a simple project to help you in reviewing array manipulation. Be sure and document the program as requested.
You problem involves reading in a collection of arrays of integers from a file and then processing each array. Each data set will contain a single array with the first value giving the number of integers that follow. The maximum number of integers for each line is 50 and the values are between 0 and +100. For each data set, output the array in the same order with the duplicate integers removed, one space between the integers. Place a blank line between each data set output. Note that the first occurrence of any duplicated integer is the one that remains in the array after removal. You are to write a function int * RemDups(int A, int size, int newsize) that returns the cleaned up array and its newsize. Call this function and then print the returned array as requested.Here is an example data file input and program output. BTW you can either write the output to the screen or to a file. I don’t care. If to the screen you just need to copy the output windows contents and print it. Staple the source and output together and turn in.Example input file 5 1 2 2 3 4 11 3 55 5 4 6 7 4 5 7 10 1 Example output 1 2 3 4 3 55 5 4 6 7 10 1
Your program starts by requesting the file name. It then opens the file and then proceeds to read, process and output each line to standard output. Use dynamic memory allocation for each array, after deleting the previous one. Allocate only the array size needed. You may use any algorithm of your choice but do take time to create as efficient algorithm as you can come up with. There is a very simple O(n2) algorithm. I will not count off for an inefficient program at this point since this is what this course is all about. Just THINK about it. Would your program work well even if an array had 1,000,000 integers in it? Problems similar to this are often interview questions. We will look at faster methods for this problem as we progress thru the course.
NOTE: I requested using old c++ dynamic allocation for the array for review purposes and to remind you the complications that it creates. You need to know this to work on legacy code. Modern C++ developers use vectors<type> instead. We will look at the standard template library, which defines vectors a little later.
Do your own work and do not copy or even read another student’s program. I will help you if you are having problems. Start on it now! Late projects will be severely penalized.