Advertisement
SergeyPGUTI

8.2.3(2)

Feb 18th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 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,nMax=0,Sum=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.         Sum=0;
  31.         for(int j=0;j<m;j++)
  32.             {
  33.                 Sum+=p[i][j];
  34.             }
  35.         if (Sum>Max) {
  36.                 Max=Sum;
  37.                 nMax=i;
  38.                 }
  39.     }
  40.        cout<<Max<<endl;
  41.        cout<<nMax;
  42.  
  43.  
  44.     //вывод p
  45. //    for (int i=0;i<n;i++)
  46. //    {
  47. //
  48. //        for (int j=0;j<n;j++)
  49. //            {
  50. //                cout<<p[i][j]<<" ";
  51. //            }
  52. //            cout<<endl;
  53. //    }
  54.  
  55.  
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement