Quipex icon

Laba_5.5_XIII

Quipex | PRO | 10/22/15 11:12:57 PM UTC | 0 ⭐ | 251 👁️ | Never ⏰ | []
C++ |

1 KB

|

None

|

0 👍

/

0 👎

// Laba_5.5_XIII.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <iostream>
using namespace std;
 
 
int main()
{
    int n,m,i,j;
    cout<<"Vvedite n i m:\n";
    cin>>n>>m;
    double **mas;
    mas = new double*[n];
    for (int i=0 ; i<n ; i++ )
        mas[i] = new double[n];
 
    double nmax,nmin;
    bool flagmin=true, flagmax=true;
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
        {
            cin>>mas[i][j];
            //min vishe glavnoj
            if((flagmin) && (j>i))
            {
                nmin=mas[i][j];
                flagmin=false;
            }
            else
                if ((j>i) && (mas[i][j]<nmin))
                    nmin=mas[i][j];
            
            //max nizhe pobochnoj
            if((flagmax) && (j>n-i-1))
            {
                nmax=mas[i][j];
                flagmax=false;
            }
            else
                if ((j>n-i-1) && (nmax<mas[i][j]))
                    nmax=mas[i][j];
        }
    for(i=0; i<n; i++)
    delete [ ]mas[i];
    delete [ ]mas;
    mas=NULL;
    cout<<"\nmax sredi elem nizhe pobochnoj="<<nmax<<endl;
    cout<<"\nmin sredi elem vishe glavnoj="<<nmin<<endl; 
    system("pause");
    return 0;
}

Comments