Advertisement
SergeyPGUTI

8.2.7

Feb 18th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 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.  
  29.     for (int i=0;i<n;i++)
  30.     {
  31.  
  32.         for(int j=0;j<m;j++)
  33.             {
  34.  
  35.                 if (p[i][j]>Max)
  36.                 {
  37.                     Max=p[i][j];
  38.                     MaxCount=1;
  39.                     iMax=i;
  40.                 }
  41.                 if (p[i][j]==Max && i!=iMax)
  42.                 {
  43.                     MaxCount++;
  44.                     iMax=i;
  45.                 }
  46.  
  47.             }
  48.  
  49.     }
  50.  
  51.  
  52.        cout<<MaxCount<<endl;
  53.        for (int i=0;i<n;i++)
  54.     {
  55.  
  56.         for(int j=0;j<m;j++)
  57.             {
  58.  
  59.                 if (p[i][j]==Max)
  60.                 {
  61.                     cout<<i<<" ";
  62.                     break;
  63.                 }
  64.             }
  65.  
  66.     }
  67.  
  68.  
  69.     return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement