AddO1f

Говно собачье_3

Mar 22nd, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 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],max=0,min=0,k1,k2,pl=0,mn=0,nl=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[max][j])
  25.             max=i;
  26.             if (a[i][j]<a[min][j])
  27.             min=i;
  28.             if (a[i][j]>0)
  29.             pl=pl+1;
  30.             else if (a[i][j]<0)
  31.             mn=mn+1;
  32.             else nl=nl+1;
  33.         }
  34.         k1=a[max][j]; k2=a[min][j];
  35.         a[max][j]=a[0][j]; a[0][j]=k1;
  36.         a[min][j]=a[i-1][j]; a[i-1][j]=k2;
  37.         max=min=0;
  38.     }
  39.     cout<<endl<<"Матрица A: \n";
  40.     for (i=0; i<N; i++)
  41.     {
  42.         for (j=0; j<M; j++)
  43.         cout<<a[i][j]<<"\t";
  44.         cout<<endl;
  45.     }
  46.     cout<<endl;
  47.     cout<<"Положительных элементов: "<<pl<<endl;
  48.     cout<<"Отрицательных элементов: "<<mn<<endl;
  49.     cout<<"Нулевых элементов: "<<nl<<endl;
  50.     system("pause");
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment