Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int lenght = 0;
  8. cin >> lenght;
  9. const int len = lenght;
  10. int counter0 = 0;
  11. int counter1 = 0;
  12. int counter2 = 0;
  13. int counter3 = 0;
  14. int counter4 = 0;
  15. int counter5 = 0;
  16. int counter6 = 0;
  17. int counter7 = 0;
  18. int counter8 = 0;
  19. int counter9 = 0;
  20. int etalonArr[10] = {0,1,2,3,4,5,6,7,8,9};
  21. int newArr[10];
  22. int arr[len] = {};
  23. int maxValue = INT_MIN;
  24.  
  25. for(int i = 0; i < lenght; i ++){
  26. cin >> arr[i];
  27. }
  28.  
  29. for(int k = 0; k < lenght; k ++){
  30. if(arr[k] == 0){
  31. counter0++;
  32. }
  33. if(arr[k] == 1){
  34. counter1++;
  35. }
  36. if(arr[k] == 2){
  37. counter2++;
  38. }
  39. if(arr[k] == 3){
  40. counter3++;
  41. }
  42. if(arr[k] == 4){
  43. counter4++;
  44. }
  45. if(arr[k] == 5){
  46. counter5++;
  47. }
  48. if(arr[k] == 6){
  49. counter6++;
  50. }
  51. if(arr[k] == 7){
  52. counter7++;
  53. }
  54. if(arr[k] == 8){
  55. counter8++;
  56. }
  57. if(arr[k] == 9){
  58. counter9++;
  59. }
  60. }
  61.  
  62. newArr[0] = counter0;
  63. newArr[1] = counter1;
  64. newArr[2] = counter2;
  65. newArr[3] = counter3;
  66. newArr[4] = counter4;
  67. newArr[5] = counter5;
  68. newArr[6] = counter6;
  69. newArr[7] = counter7;
  70. newArr[8] = counter8;
  71. newArr[9] = counter9;
  72.  
  73. // for(int d = 0; d < 10; d ++){
  74. // cout << newArr[d] << " ";
  75. // }
  76.  
  77. for(int d = 0; d < 10; d ++){
  78. if(newArr[d] > maxValue){
  79. maxValue = newArr[d];
  80. }
  81. }
  82. // cout << endl;
  83. // cout << maxValue;
  84. // cout << endl;
  85.  
  86. for(int y = 0; y < 10; y ++){
  87.  
  88. if(newArr[y] == maxValue){
  89. cout << etalonArr[y] << " ";
  90. }
  91.  
  92. }
  93.  
  94.  
  95.  
  96. return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement