Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include "math.h"
- #include "iostream"
- #include "iomanip"
- using namespace std;
- int main()
- {
- setlocale (LC_ALL, "RUS");
- int i,j,N,M,a[30][30],sum1,c,l,max,min,sum2;
- cout<<"N=";
- cin>>N;
- cout<<"M=";
- cin>>M;
- cout<<"Ввод матрицы А \n";
- sum1 = 0;
- sum2 = 0;
- c = 0;
- l = 0;
- max = a[0][0];
- for (i=0; i<N; i++)
- for (j=0; j<M; j++)
- cin>>a[i][j];
- cout<<"Матрица А \n";
- for (i=0; i<N; i++)
- {
- for (j=0; j<M; j++)
- cout<<a[i][j]<<"\t";
- cout<<endl;
- }
- for (l = 0; l<N; l++)
- {
- for (c = 0; c < M; c++)
- {
- sum1 += a[l][c];
- }
- cout << "Сумма строки №"<< l+1 <<"= "<< sum1 << "\n";
- sum1 = 0;
- }
- for (l = 0; l<M; l++)
- {
- for (c = 0; c < N; c++)
- {
- sum2 += a[c][l];
- }
- cout << "Сумма столбца №"<< l+1 <<"= "<< sum2 << "\n";
- sum2 = 0;
- }
- for (i = 0; i < N; i++)
- {
- for (j = 0; j<M; j++)
- {
- if (a[i][j]>max)
- {
- max = a[i][j];
- }
- }
- }
- cout << "Максимальный элемент матрицы = " << max << "\n";
- min = a[0][0];
- for (i = 0; i < N; i++)
- {
- for (j = 0; j<M; j++)
- {
- if (a[i][j]<min)
- {
- min = a[i][j];
- }
- }
- }
- cout << "Минимальный элемент матрицы = " << min << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement