#include
using namespace std;
#include
#define max(x,y) ((x)<(y)?(y):(x))
#define min(x,y) ((x)>(y)?(y):(x))
int main(void)
{
int i,j;
double maxa,mina;
double a[3][4]={{1,2,3,4},{2,3,4,0.2},{2.3,91,0.2,-0.1}};
//3*4的矩阵
maxa=a[0][0];
mina=a[0][0];
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
maxa=max(a[i][j],maxa);
mina=min(a[i][j],mina);
}
}
cout<<"max: "<
return 0;
}
#include
#define N 3 //3*3矩阵
int main()
{
int a[N][N]={{1,2,3},{4,5,6},{7,8,9}};
int max=a[0][0];
int min=a[0][0];
int i;
int j;
for(i=0;i
for(j=0;j
if(max {
max = a[i][j];
}
if(min>a[i][j])
{
min = a[i][j];
}
}
}
cout<<"max="<
return 0;
}
将每行看着一个一维数组,然后问题转换为求一维数组的最大最小值
int find_max_min(int *array,int len,int *min, int *max)
{
int i=0;
min=max=array[i];
while(i
if(array[i]>max)
{
max=array[i];
}
if(array[i]
min=array[i];
}
i++
}
return 0;
}
另外,虚机团上产品团购,超级便宜