Computer Programming help?

Computer Programming. PLEASE HELP!!!! BEST ANSWER!!!!?

  • Computer Programming. Please Help!!!! BEST ANSWER!!!!? In C++ Write a program that reads in an array of type int. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries are used. The output is to be a two-column list. The first column is a list of distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest. EXAMPLE: For array values: -12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12 The output should be: N Count 4 2 3 3 2 2 1 4 -1 1 -12 4 I NEED TO USE FUNCTIONS. This is my code. I need help, it's not working: #include <iostream> #include <stdlib.h> using namespace std; void fillArray(int a[], int SIZE, int& lastElement); void sort(int a[], int lastElement); void swapValues(int& v1, int& v2); int indexSmallest(const int a[], int startIndex, int lastElement); void showFrequency (int a[], int SIZE); int main( ) { using namespace std; const int SIZE = 50; int arr[SIZE] = {0}; int lastElement; //the index cout << "Enter scores:\n"; fillArray (arr, SIZE, lastElement); sort (arr, lastElement); showFrequency (arr, lastElement); system ("PAUSE"); return 0; } void fillArray(int a[], int SIZE, int& lastElement) { cout << "Enter up to " << SIZE << " whole numbers.\n"; int next, index = 0; cin >> next; while ((next >= 0) && (index < SIZE)) { a[index] = next; index++; cin >> next; } lastElement = index; } void sort(int a[], int lastElement) { int index_of_next_smallest; for (int index = 0; index < lastElement - 1; index++) { index_of_next_smallest = indexSmallest(a, index, lastElement); swapValues(a[index], a[index_of_next_smallest]); } } void swapValues(int& v1, int& v2) { int temp; temp = v1; v1 = v2; v2 = temp; } int indexSmallest(const int a[], int startIndex, int lastElement) { int min = a[startIndex], index_of_min = startIndex; for (int index = startIndex + 1; index < lastElement; index++) if (a[index] < min) { min = a[index]; index_of_min = index; //min is the smallest of a[start_index] through a[index] } return index_of_min; } void showFrequency (int a[], int SIZE) { int prev = a[0], freq = 1; cout << "Number count \n"; cout << a[0] << " "; for (int i=1; i<= SIZE; i++) { if (prev == a[i]) freq++; else { cout << freq; cout << a[i] << " "; freq = 1; prev = a[i]; } } cout << freq << endl; }

  • Answer:

    Jesus christ, INDENT THAT SOURCE UP.

Stephanie I at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

probably you can't indent on here. I have no idea sweetheart. This is beyond my abilities.

0100100100100000 011101110110000101101110 0111010000100000 011101000110111100100000 0110011001110101 011000110110101100100000 0111100101101111 0111010100101110

Use pastebin.com, then try again.

I dont know...

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.