1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int responseSize = 20;
const int frequencySize = 6;
unsigned int responses[responseSize] = {1, 2, 5, 4, 3 , 5, 2, 1, 3, 1, 4,3,3,3,2,3,3,2,2,5};
unsigned int frequency [frequencySize] = {};
for (size_t answer = 0; answer < (sizeof(responses) - 1); ++answer)
++frequency [ responses[answer]];
cout << "Rating" << setw(17) << "Frequency" << endl;
for (size_t rating = 1; rating < (sizeof(frequency) - 1); ++rating)
cout << setw(6) << rating << setw(17) << frequency [rating] << endl;
return 0;
}
|