在vc++6.0上运行结构体
#include<stdio.h>#defineN5structstudent{intnum;charname[20];floatscore;};voidmain(){s...
#include<stdio.h>
#define N 5
struct student
{ int num;
char name[20];
float score;
};
void main()
{ struct student stu[5]={{10101,"Zhang",78},{10103,"Wang",98.5}{10106,"Li",86},{10108,"Ling",78},{10110,"Fun",100}};
struct student temp;
int i,j,k;
printf("The order is:\n");
for(i=0;i<N-1;i++)
{ k=i;
for(j=i+1;j<N;j++)
if(stu[j].score>stu[k].score)
k=j;
temp=stu[k];stu[k]=stu[i];stu[i]=temp;
}
for(i=0;i<N;i++)
printf("%6d%8s%6.2f\n",stu[i].num,stu[i].name,stu[i].score);
printf("\n");
}
我什么错误都找不出来啊,麻烦麻烦 展开
#define N 5
struct student
{ int num;
char name[20];
float score;
};
void main()
{ struct student stu[5]={{10101,"Zhang",78},{10103,"Wang",98.5}{10106,"Li",86},{10108,"Ling",78},{10110,"Fun",100}};
struct student temp;
int i,j,k;
printf("The order is:\n");
for(i=0;i<N-1;i++)
{ k=i;
for(j=i+1;j<N;j++)
if(stu[j].score>stu[k].score)
k=j;
temp=stu[k];stu[k]=stu[i];stu[i]=temp;
}
for(i=0;i<N;i++)
printf("%6d%8s%6.2f\n",stu[i].num,stu[i].name,stu[i].score);
printf("\n");
}
我什么错误都找不出来啊,麻烦麻烦 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询