#include<iostream.h> int main() { int m,n,i,j; cout<<"nhap vao ma tran co m x n"<<endl;cin>>m;cin>>n; int a[200][200]; for(i=0;i<m;i++) { for(j=0;j<n;j++) { cout<<"nhap vao a["<<i<<"]["<<j<<"]"; cin>>a[j]; } cout<<endl; } //hien thi int t1,t2,t3,t4; for(i=0;i<m;i++) { int max=a[0],min=a[0]; for(j=0;j<n;j++) if(a[j]<=min) { min=a[j];t1=i;t2=j; } else if(a[j]>=max) { max=a[j];t3=i;t4=j; } cout<<"gia tri nho nhat trong hang "<<i+1<<"la a["<<t1<<"]["<<t2<<"]"<<min<<endl; cout<<"gia tri lon nhat trong hang "<<i+1<<"la a["<<t3<<"]["<<t4<<"]"<<max<<endl; } //theo hang min ,max for(j=0;j<n;j++) { int max=a[0][j],min=a[0][j]; for(i=0;i<m;i++) if(a[j]<=min) { min=a[j];t1=i;t2=j; } else if(a[j]>=max) { max=a[j];t3=i;t4=j; } cout<<"gia tri nho nhat trong cot "<<j+1<<"la a["<<t1<<"]["<<t2<<"]"<<min<<endl; cout<<"gia tri lon nhat trong cot "<<j+1<<"la a["<<t3<<"]["<<t4<<"]"<<max<<endl; } // theo cot min,max return 0; }