该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
#include
#include
#define NMAX 10
#define n 10
struct student
{ char name[NMAX];
int score;
} info[n];
int main ( )
{ int num, i, j, max, temp1;
char temp2[NMAX];
printf("#####欢迎使用学生信息统计系统#####");
printf("\n请输入%d个学生的成绩: \n",n);
for (i=0; i
{
printf ("姓名:");
scanf ("%s", info[i].name);
printf ("成绩:");
scanf ("%d", &(info[i].score));
}
num=1;
printf("-------------------\n");
printf("名次 姓名 成绩\n");
for (i=0; i
{ max=i;
for (j=i+1; j
if (info[j].score>info[max].score)
max=j;
if (max!=i)
{ temp1 = info[max].score;
info[max]=info[i];
info[i].score= temp1;
strcpy(temp2,info[max].name);
strcpy(info[max].name,info[i].name);
strcpy(info[i].name,temp2);
}
if ((i>0)&&(info[i].score
num=num+1;
printf("%4d %s %4d \n", num, info[i].name, info[i].score);
}
getch();
printf("#########调试完毕#########\n");
return 0;
}