Advertisement
Mr_D3a1h

Untitled

Sep 29th, 2019
203
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 = a[0][0];
  14.     min = a[0][0];
  15.     for (i=0; i<N; i++)
  16.     for (j=0; j<M; j++)
  17.     cin>>a[i][j];
  18.     cout<<"Матрица А \n";
  19.     for (i=0; i<N; i++)
  20.     {
  21.         for (j=0; j<M; j++)
  22.         cout<<a[i][j]<<"\t";
  23.         cout<<endl;
  24.     }
  25.    
  26.     for (l = 0; l<N; l++)
  27.     {
  28.         for (c = 0; c < M; c++)
  29.         {
  30.             x += a[l][c];
  31.         }
  32.         cout << "Сумма строки №"<< l+1 <<"= "<< x << "\n";
  33.         x = 0;
  34.     }
  35.     for (i = 0; i < N; i++)
  36.     {
  37.         for (j = 0; j<M; j++)
  38.         {
  39.             if (a[i][j]>max)
  40.             {
  41.                 max = a[i][j];
  42.             }
  43.         }
  44.     }
  45.     cout << "Максимальный элемент матрицы = " << max << "\n";
  46.     for (i = 0; i < N; i++)
  47.     {
  48.         for (j = 0; j<M; j++)
  49.         {
  50.             if (a[i][j]<min)
  51.             {
  52.                 min = a[i][j];
  53.             }
  54.         }
  55.     }
  56.     cout << "Минимальный элемент матрицы = " << min << "\n";
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement