Quipex

Laba_5.5_XIII

Oct 22nd, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. // Laba_5.5_XIII.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. using namespace std;
  7.  
  8.  
  9. int main()
  10. {
  11.     int n,m,i,j;
  12.     cout<<"Vvedite n i m:\n";
  13.     cin>>n>>m;
  14.     double **mas;
  15.     mas = new double*[n];
  16.     for (int i=0 ; i<n ; i++ )
  17.         mas[i] = new double[n];
  18.  
  19.     double nmax,nmin;
  20.     bool flagmin=true, flagmax=true;
  21.     for(i=0;i<m;i++)
  22.         for(j=0;j<n;j++)
  23.         {
  24.             cin>>mas[i][j];
  25.             //min vishe glavnoj
  26.             if((flagmin) && (j>i))
  27.             {
  28.                 nmin=mas[i][j];
  29.                 flagmin=false;
  30.             }
  31.             else
  32.                 if ((j>i) && (mas[i][j]<nmin))
  33.                     nmin=mas[i][j];
  34.            
  35.             //max nizhe pobochnoj
  36.             if((flagmax) && (j>n-i-1))
  37.             {
  38.                 nmax=mas[i][j];
  39.                 flagmax=false;
  40.             }
  41.             else
  42.                 if ((j>n-i-1) && (nmax<mas[i][j]))
  43.                     nmax=mas[i][j];
  44.         }
  45.     for(i=0; i<n; i++)
  46.     delete [ ]mas[i];
  47.     delete [ ]mas;
  48.     mas=NULL;
  49.     cout<<"\nmax sredi elem nizhe pobochnoj="<<nmax<<endl;
  50.     cout<<"\nmin sredi elem vishe glavnoj="<<nmin<<endl;
  51.     system("pause");
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment