[求助]加上冒泡排序
下面的程序在哪加上冒泡排序?怎么加 ? 我在main()函数里加上后为什么只排总成绩?其他的怎么不变啊? 急用#include <stdio.h>
#define N 3
struct student
{ char num[6];
char name[8];
int score[3];
double total;
}
stu[N];
void main()
{ int i,j,sum;
for(i=0;i<N;i++)
{ printf("\n please input NO.%d score:\n",i+1);
printf("stuNO.:");
scanf("%s",stu[i].num);
printf("name:");
scanf("%s",stu[i].name);
sum=0;
printf("score 1 shuxuechengji\t score 2 jisuanjichengji\t score 3 yingyuchengji\n");
for(j=0;j<3;j++)
{ printf("%d",j+1);
scanf("%d",&stu[i].score[j]);
sum+=stu[i].score[j];
}
stu[i].total=sum;
printf("zongchengjiwei:%g\n",stu[i].total);
if(stu[i].total>=270)
printf("you");
else if(stu[i].total>=180)
printf("jige");
else printf("bujige");
}
{int i,j;
printf("\n===================cheng ji biao============================");
printf("\n NO. name score1 score2 score3 zongchengji pingyu\n");
for(i=0;i<N;i++)
{printf("%4s%6s",stu[i].num,stu[i].name);
for(j=0;j<3;j++)
printf("%9d",stu[i].score[j]);
printf("%9g",stu[i].total);
printf(" ");
if(stu[i].total>=270)
printf("you");
else if(stu[i].total>=180)
printf("jige");
else printf("bujige");
printf("\n");
printf("************************************************************");
printf("\n");
}
}
}