Advertisement
SergeyPGUTI

8.2.5

Feb 18th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 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=0,jMax=0,Sum=0,SumMax=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.                 if (p[i][j]==Max) {
  34.                         Sum=0;
  35.                     for (int l=0;l<m;l++)
  36.                         {
  37.                             Sum+=p[i][l];
  38.                         }
  39.                     if (Sum>SumMax)  
  40.                     {
  41.                         SumMax=Sum;
  42.                         Max=p[i][j];
  43.                         iMax=i;
  44.                     }
  45.                 }
  46.  
  47.                 if (p[i][j]>Max) {
  48.                     SumMax=0;
  49.                     Max=p[i][j];
  50.                     iMax=i;
  51.                     for (int l=0;l<m;l++)
  52.                     {
  53.                         SumMax+=p[i][l];
  54.                     }
  55.  
  56.                 }
  57.             }
  58.  
  59.     }
  60.        cout<<iMax<<endl;
  61.  
  62.  
  63.     //вывод p
  64. //    for (int i=0;i<n;i++)
  65. //    {
  66. //
  67. //        for (int j=0;j<n;j++)
  68. //            {
  69. //                cout<<p[i][j]<<" ";
  70. //            }
  71. //            cout<<endl;
  72. //    }
  73.  
  74.  
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement