Advertisement
Mr_D3a1h

Untitled

Sep 28th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. int main()
  2. {
  3.     setlocale (LC_ALL, "RUS");
  4.     int i,j,N,M,a[30][30],x,c,l,max,min;
  5.     cout<<"N=";
  6.     cin>>N;
  7.     cout<<"M=";
  8.     cin>>M;
  9.     cout<<"Ввод матрицы А \n";
  10.     x = 0;
  11.     c = 0;
  12.     l = 0;
  13.     max = -1e10;
  14.     min = 1e10;
  15.     for (i=0; i<N; i++)
  16.  
  17.     for (j=0; j<M; j++)
  18.     cin>>a[i][j];
  19.     cout<<"Матрица А \n";
  20.     for (i=0; i<N; i++)
  21.     {
  22.  
  23.         for (j=0; j<M; j++)
  24.         cout<<a[i][j]<<"\t";
  25.         cout<<endl;
  26.     }
  27.    
  28.     for (l = 0; l<N; l++)
  29.     {
  30.         for (c = 0; c < M; c++)
  31.         {
  32.             x += a[l][c];
  33.         }
  34.         cout << "Сумма строки №"<< l+1 <<"= "<< x << "\n";
  35.         x = 0;
  36.     }
  37.     for (i = 0; i < N; i++)
  38.     {
  39.         for (j = 0; j<M; j++)
  40.         {
  41.             if (a[i][j]>max)
  42.             {
  43.                 max = a[i][j];
  44.             }
  45.         }
  46.     }
  47.     cout << "Максимальный элемент матрицы = " << max << "\n";
  48.     for (i = 0; i < N; i++)
  49.     {
  50.         for (j = 0; j<M; j++)
  51.         {
  52.             if (a[i][j]<min)
  53.             {
  54.                 min = a[i][j];
  55.             }
  56.         }
  57.     }
  58.     cout << "Минимальный элемент матрицы = " << min << "\n";
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement