#include <stdio.h>
void main()
{
int a[3][2]={
{
79,46}
,{
78,36}
,{
58,80}
}
,i,j;
int t=0,s=0;
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
if(t<a[0][j])
t=a[0][j];
if(s<a[1][j])
s=a[1][j];
}
printf("第一门高数:%d/n",t);
printf("第二门高数:%d\n",s);
}
}
把输出语句放外面,不一样啊
#include <stdio.h>
int main()
{
int a[3][2]={
{79,46},{78,36},{58,80}
};
int i,j;
int t=0,s=0;
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
if(t<a[0][j])
t=a[0][j];
if(s<a[1][j])
s=a[1][j];
}
}
printf("第一门高数:%d\n",t);
printf("第二门高数:%d\n",s);
}
运行结果:
//for(i=0; i<2; i++)
{
for(j=0; j<3; j++)
{
if(t<a[j][0])
t=a[j][0];
if(s<a[j][1])
s=a[j][1];
}
printf("第一门高数:%d\n",t);
printf("第二门高数:%d\n",s);
}