Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //*Программа, подсчитывающая число элементов, равных максимуму, в числовом массиве из 30-и элементов
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main ()
- {
- unsigned short m[30];
- srand (time(NULL));
- int i=0, k=0, max=0;
- while (i<30)
- {
- m[i]=rand();
- i++;
- }
- i=0;
- while (i<30)
- {
- if (m[i]>max)
- {
- max=m[i];
- k=1;
- }
- else
- {
- if (m[i]==max)
- k++;
- }
- }
- cout<<"max = "<<max<<endl<<k<<"raz";
- cin.sync();
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement