Advertisement
Domerk

С2_2

Mar 8th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. //*Программа, подсчитывающая число элементов, равных максимуму, в числовом массиве из 30-и элементов
  2.  
  3. #include <iostream>
  4. #include <cstdlib>
  5. #include <ctime>
  6. using namespace std;
  7. int main ()
  8. {
  9.     unsigned short m[30];
  10.     srand (time(NULL));
  11.     int i=0, k=0, max=0;
  12.  
  13.     while (i<30)
  14.     {
  15.         m[i]=rand();
  16.         i++;
  17.     }
  18.  
  19.     i=0;
  20.     while (i<30)
  21.     {
  22.         if (m[i]>max)
  23.         {
  24.             max=m[i];
  25.             k=1;
  26.         }
  27.         else
  28.         {
  29.         if (m[i]==max)
  30.         k++;
  31.         }
  32.     }
  33.     cout<<"max = "<<max<<endl<<k<<"raz";
  34.     cin.sync();
  35.     cin.get();
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement