Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #define w "kratki"
  4.  
  5. using namespace std;
  6.  
  7. int main(int argc, char** argv) {
  8.  
  9. setlocale(LC_ALL,"");
  10.  
  11. int tab4[30];
  12.  
  13. for (int i=0; i<30; i++){
  14. tab4[i] = rand()%11;
  15. cout << tab4[i] << " ";
  16. }
  17.  
  18. for (int j=0; j<30; j++)
  19. for (int i=0; i<29; i++)
  20. if (tab4[i]>tab4[i+1])
  21. swap(tab4[i],tab4[i+1]);
  22.  
  23. cout << endl;
  24.  
  25.  
  26.  
  27. for (int i=0; i<30; i++){
  28. cout << tab4[i] << " ";
  29.  
  30. }
  31.  
  32. cout << endl;
  33.  
  34. max = 0;
  35. int maxi = 0;
  36. s = 1;
  37.  
  38. for (int i=0; i<29; i++){
  39. if (tab4[i] == tab4[i+1]) {
  40. s++;
  41. }
  42. else {
  43. if (s>max) {
  44. maxi = tab4[i];
  45. max = s;
  46. }
  47. s = 1;
  48. }
  49. }
  50.  
  51. cout << max << " " << maxi;
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement