AddO1f

Lab10_2

Mar 22nd, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. #include "iomanip"
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     setlocale (LC_ALL, "RUS");
  11.     int i,j,N,M,a[20][20],k=0,sum=0;
  12.     cout<<"Введите количество строк: "; cin>>N;
  13.     cout<<"Введите количество столбцов: "; cin>>M;
  14.     cout<<"Введите матрицу A: \n";
  15.     for (i=0; i<N; i++)
  16.     {
  17.         for (j=0; j<M; j++)
  18.         cin>>a[i][j];
  19.     }
  20.     for (j=0; j<M; j++)
  21.     {
  22.         for (i=0; i<N; i++)
  23.         {
  24.             if (a[i][j]<a[k][j])
  25.             k=i;
  26.             if (a[i][j]>0)
  27.             sum=sum+a[i][j];
  28.         }
  29.         a[k][j]=sum;
  30.         //cout<<k<<setw(5)<<sum<<endl;
  31.         sum=k=0;
  32.     }
  33.     cout<<endl<<"Матрица A: \n";
  34.     for (i=0; i<N; i++)
  35.     {
  36.         for (j=0; j<M; j++)
  37.         cout<<a[i][j]<<"\t";
  38.         cout<<endl;
  39.     }
  40.     system("pause");
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment