Advertisement
SergeyPGUTI

8.2.6

Feb 18th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8.  
  9.  
  10. int main()
  11. {
  12.     int n,m,Max=0,iMax=-1,MaxCount=0;
  13.     cin>>n;
  14.     cin>>m;
  15.     int ** p= new int*[n];
  16.  
  17.     for (int i=0;i<n;i++)
  18.     {
  19.         p[i]=new int[m];
  20.     }
  21.  
  22.     for(int i=0;i<n;i++)
  23.     {
  24.         for(int j=0;j<m;j++)
  25.             cin>>p[i][j];
  26.     }
  27.  
  28.     for (int i=0;i<n;i++)
  29.     {
  30.  
  31.         for(int j=0;j<m;j++)
  32.             {
  33.  
  34.                 if (p[i][j]>Max)
  35.                 {
  36.                     Max=p[i][j];
  37.                     iMax=i;
  38.                     MaxCount=1;
  39.                 }
  40.                 if (Max==p[i][j] && i!=iMax) // тоже победитель но на новой строке
  41.                 {
  42.                     MaxCount++;
  43.                     iMax=i;
  44.                 }
  45.             }
  46.  
  47.     }
  48.        cout<<MaxCount<<endl;
  49.  
  50.  
  51.  
  52.  
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement