Advertisement
Infernale

NCTU LAB 12/03 NUM 3

Mar 12th, 2019
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.     vector <int> data;
  6.     int below=0, above=0, index, n;
  7.     int interval[10] = {0};
  8.     double mean = 0;
  9.     while(cin >> n){
  10.         data.push_back(n);
  11.         interval[n/10 == 10 ? 9 : n/10]++;
  12.         mean+=n;
  13.     }
  14.     sort(data.begin(), data.end());
  15.     mean/=data.size();
  16.     for(index=0;index<data.size();index++){
  17.         if(data[index]<mean){
  18.             below++;
  19.         }
  20.         if(data[index]>mean){
  21.             above++;
  22.         }
  23.     }
  24.     cout << "**** Score Report ****" << endl << endl;
  25.     cout << "Mean: " << fixed << setprecision(2) << mean << endl;
  26.     cout << "Above Mean: " << above << endl;
  27.     cout << "Below Mean: " << below << endl << endl;
  28.     for(int i=0;i<10;i++){
  29.         cout << i*10 << " ~ " << i*10+9+(i==9) << ": ";
  30.         for(int j=interval[i];j>0;j--){
  31.             cout << "*";
  32.         }
  33.         cout << endl;
  34.     }
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement