Min and Max element of the matrix
#include <iostream>
using namespace std;
int n,m,i,j;
float a[10][10];
void citire()
★ {
| for(i=1;i<=n;i++)
| for(j=1;j<=m;j++)
|★ {
|| cout<<"a["<<i<<"]["<<j<<"]=";
|| cin>>a[i][j];
|★ }
★ }
void compare()
★ {
| float min,max;
| min=a[1][1];
| max=a[1][1];
| for(i=1;i<=n;i++)
| for(j=1;j<=m;j++)
|★ {
| min=a[1][1];
| max=a[1][1];
| for(i=1;i<=n;i++)
| for(j=1;j<=m;j++)
|★ {
|| if(min>a[i][j])
|| min=a[i][j];
|| if(max<a[i][j])
|| max=a[i][j];
|| min=a[i][j];
|| if(max<a[i][j])
|| max=a[i][j];
|★ }
|
| cout<<"Valoarea maxima este="<<max<<endl;
| cout<<"Valoarea maxima este="<<max<<endl;
| cout<<"Valoarea minima este="<<min<<endl;
★ }
★ }
★ int main()
| {
| cout<<"Numarul de linii este ";cin>>n;
| cout<<"Numarul de coloane este ";cin>>m;
| citire();
| compar();
| cout<<"Numarul de linii este ";cin>>n;
| cout<<"Numarul de coloane este ";cin>>m;
| citire();
| compar();
|
| return 0;
★ }
| return 0;
★ }
Niciun comentariu:
Trimiteți un comentariu