1个回答
展开全部
先把二维数组倒成一位数组,然后在里面找
in[][] array = new int[4][5]; //二维数组
int[] newarray = new int[20];
int k =0;
for(int i = 0;i<4;i++)
{
for(int j = 0;j<5;j++)
{
newarray[k] = array[i][j];
}
}
int max = 0;
int min = int.MaxValue;
for(int i = 0;i<newarray.length;i++)
{
if(newarray[i]>max)
{
max = newarray[i];
}
if(newarray[i]<min)
{
min = newarray[i];
}
}
Console,WriteLine("Max number is :"+max);
Console,WriteLine("Min number is :"+min);
in[][] array = new int[4][5]; //二维数组
int[] newarray = new int[20];
int k =0;
for(int i = 0;i<4;i++)
{
for(int j = 0;j<5;j++)
{
newarray[k] = array[i][j];
}
}
int max = 0;
int min = int.MaxValue;
for(int i = 0;i<newarray.length;i++)
{
if(newarray[i]>max)
{
max = newarray[i];
}
if(newarray[i]<min)
{
min = newarray[i];
}
}
Console,WriteLine("Max number is :"+max);
Console,WriteLine("Min number is :"+min);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询