fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n;
  7. cin >> n;
  8. int one= 0, two= 0, three= 0, four = 0, five = 0, six = 0, seven = 0, eight = 0, nine = 0;
  9. vector<int> a;
  10.  
  11. for (int j = 0; j < n; ++j){
  12. int b;
  13. cin >> b;
  14. a.push_back(b);
  15. }
  16.  
  17. for (int i = 0; i < n; ++i){
  18. if (a[i] == 1){
  19. ++one;
  20. }
  21. if (a[i] == 2){
  22. ++two;
  23. }
  24. if (a[i] == 3){
  25. ++three;
  26. }
  27. if (a[i] == 4){
  28. ++four;
  29. }
  30. if (a[i] == 5){
  31.  
  32. ++five;
  33. }
  34. if (a[i] == 6){
  35.  
  36. ++six;
  37. }
  38. if (a[i] == 7){
  39.  
  40. ++seven;
  41. }
  42. if (a[i] == 8){
  43.  
  44. ++eight;
  45. }
  46. if (a[i] == 9){
  47.  
  48. ++nine;
  49. }
  50. }
  51. cout << one << " " << two << " " << three << " " << four << " " << five << " " << six << " " << seven << " " << eight << " " << nine;
  52. return 0;
  53. }
Success #stdin #stdout 0s 5308KB
stdin
5
8 2 5 8 8
stdout
0 1 0 0 1 0 0 3 0