fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. // count array for brackets 0 to 10
  7. int *count = new int[11];
  8. // variable to store each mark read
  9. int mark;
  10.  
  11. // Read in marks
  12. while (cin >> mark) {
  13. // Increment the count for the bracket the mark falls in
  14. count[mark/10]++;
  15. }
  16.  
  17. for (int i=0;i<11;i++) {
  18. cout << i << "\t| " << string(count[i],'*') << endl;
  19. }
  20.  
  21. }
Success #stdin #stdout 0s 2988KB
stdin
50
55
55
53
53
40
54
44
44
44
66
66
66
66
30
70
stdout
0	| 
1	| 
2	| 
3	| *
4	| ****
5	| ******
6	| ****
7	| *
8	| 
9	| 
10	|