Write a program that reads in a list of integers into and array with base type i
ID: 3626676 • Letter: W
Question
Write a program that reads in a list of integers into and array with base type int. Provide the facility to either read this array from the keyboard or from a file, at the user's option. If the user chooses file input, the program should request a file name. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is to be a two_column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries n the first column, largest to smallest. For example: -12 3-12 4 1 1 -12 1 -1 1 2 3 4 2 3 -2
N Count
4 2
3 3
2 2
1 4
-1 1
-12 4
Hint: Use 2 arrays, one for storing the values, the other for storing the count. For example, 5 is entered 10 times, 5 is stored once and a count of 10 is stored in the second array.
When a new number is entered, search the first array to see if the number already exists. If yes, then increment the corresponding array element (the count); if not add the new number to the end of the first array and set its count in the second array to 1, and then sort both arrays.
Explanation / Answer
this is the program u want PLEASE RATE #include #include #include #include using namespace std; //function prototypes void initialize (int numbers[], int listSize); void readNum (int numbers[], int& listSize); void selectSort (int numbers[], int listSize); void read_file(int numbers[],int&listSize); int main() { int Numbers [100]; int count= 0; int listsize = 100; int temp; int choise=0; initialize (Numbers, listsize); coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.