Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include "iomanip"
- using namespace std;
- int main()
- {
- setlocale (LC_ALL, "RUS");
- int i,j,N,M,a[20][20],k=0,sum=0;
- cout<<"Введите количество строк: "; cin>>N;
- cout<<"Введите количество столбцов: "; cin>>M;
- cout<<"Введите матрицу A: \n";
- for (i=0; i<N; i++)
- {
- for (j=0; j<M; j++)
- cin>>a[i][j];
- }
- for (j=0; j<M; j++)
- {
- for (i=0; i<N; i++)
- {
- if (a[i][j]<a[k][j])
- k=i;
- if (a[i][j]>0)
- sum=sum+a[i][j];
- }
- a[k][j]=sum;
- //cout<<k<<setw(5)<<sum<<endl;
- sum=k=0;
- }
- cout<<endl<<"Матрица A: \n";
- for (i=0; i<N; i++)
- {
- for (j=0; j<M; j++)
- cout<<a[i][j]<<"\t";
- cout<<endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment