abubaca

Untitled

Jan 16th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. using namespace std;
  4.  
  5. void search(int m[], int size, int &max, int &col)
  6. {
  7.     for (int i=0; i< size;i++)
  8.     {
  9.         if (max==m[i])
  10.             count++;
  11.         if (m[i]>max)
  12.         {
  13.             count = 1;
  14.             max=m[i];
  15.         }
  16.     }
  17. }
  18.  
  19. int main()
  20. {
  21.     ifstream fin("DATA.txt");
  22.     int n,max=0,count=0,mas[500];
  23.     fin >> n;
  24.     for (int i=0;i<n;i++)
  25.     {
  26.         fin >> mas[i];
  27.     }
  28.     fin.close();
  29.     search(mas, n, max, count);
  30.     ofstream fout("REZ.txt");
  31.     fout << max << " " << count;
  32.     fout.close();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment