Advertisement
Mr_D3a1h

Untitled

Sep 29th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.65 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include "math.h"
  4. #include "iostream"
  5. #include "iomanip"
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     setlocale (LC_ALL, "RUS");
  12.     int i,j,N,M,a[30][30],sum1,c,l,max,min,sum2;
  13.     cout<<"N=";
  14.     cin>>N;
  15.     cout<<"M=";
  16.     cin>>M;
  17.     cout<<"Ввод матрицы А \n";
  18.     sum1 = 0;
  19.     sum2 = 0;
  20.     c = 0;
  21.     l = 0;
  22.     max = a[0][0];
  23.    
  24.     for (i=0; i<N; i++)
  25.     for (j=0; j<M; j++)
  26.     cin>>a[i][j];
  27.     cout<<"Матрица А \n";
  28.     for (i=0; i<N; i++)
  29.     {
  30.         for (j=0; j<M; j++)
  31.         cout<<a[i][j]<<"\t";
  32.         cout<<endl;
  33.     }
  34.    
  35.     for (l = 0; l<N; l++)
  36.     {
  37.         for (c = 0; c < M; c++)
  38.         {
  39.             sum1 += a[l][c];
  40.         }
  41.         cout << "Сумма строки №"<< l+1 <<"= "<< sum1 << "\n";
  42.         sum1 = 0;
  43.     }
  44.     for (l = 0; l<M; l++)
  45.        {
  46.            for (c = 0; c < N; c++)
  47.            {
  48.                sum2 += a[c][l];
  49.            }
  50.            cout << "Сумма столбца №"<< l+1 <<"= "<< sum2 << "\n";
  51.            sum2 = 0;
  52.        }
  53.     for (i = 0; i < N; i++)
  54.     {
  55.         for (j = 0; j<M; j++)
  56.         {
  57.             if (a[i][j]>max)
  58.             {
  59.                 max = a[i][j];
  60.             }
  61.         }
  62.     }
  63.    
  64.     cout << "Максимальный элемент матрицы = " << max << "\n";
  65.     min = a[0][0];
  66.     for (i = 0; i < N; i++)
  67.     {
  68.         for (j = 0; j<M; j++)
  69.         {
  70.             if (a[i][j]<min)
  71.             {
  72.                 min = a[i][j];
  73.             }
  74.            
  75.         }
  76.     }
  77.     cout << "Минимальный элемент матрицы = " << min << "\n";
  78. return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement