bjbitren
传说中的水手
 
UID 29842
精华
0
积分 2
帖子 2
阅读权限 1
注册 2007-3-25
状态 离线
|
帮帮忙。。。。
我用VC6.0编一个班级成绩统计,并用冒泡法将个人总成绩排序,编译通过,可运行不出结果,那位仁兄能帮忙指点一下?不胜感激......
程序如下:
/*struct*/
#include <stdio.h>
main()
{
struct student /*定义结构体并初始化*/
{
int num;
char name[20];
float score[4];
}stu[7]={{20042100,"zhang",85.0,76.0,83.0},
{20042101,"wang",65.5,45.5,76.0},
{20042102,"li",76.0,35.0,87.0},
{20042103,"zhao",89.0,65.0,76.0},
{20042104,"zhou",67.0,79.0,98.0},
{20042105,"wu",91.0,97.0,98.0},
{20042106,"zheng",64.0,98.0,84.0}};
int i;
for(i=0;i<7;i++)
{
stu.score[3]=stu.score[0]+stu.score[1]+stu.score[2];
printf("%d",stu.score[3]);
}printf("\n");
int x;
int y;
float temp;
for(y=7;y>0;y--)
{
for(x=1;x<y;x++)
{
if((stu.score[3])>(stu[i+1].score[3]))
{
temp=(stu.score[3]);
(stu.score[3])=(stu[i+1].score[3]);
(stu[i+1].score[3])=temp;
}
}
}
int j;
for(j=0;j<=6;j++) printf("%d",stu[j].score[3]);printf("\n");
return 0;
}
[ 本帖最后由 bjbitren 于 2007-3-25 20:11 编辑 ]
|
|