下面程序的功能是:按学生的姓名查询其成绩排名和平均成绩。查询时可连续进行,直到输入“0”时才结束,请填空。
#include
#include
#define NUM 4
struct student
{ int rank;
char *name;
float score;
};
(1) stu[ ] = { 3, "liming", 89.0, 4, "zhanghua",78.2,
1, "wangming", 90.6, 2, "liqing", 96.2 };
int main(void)
{ char str[10];
int i;
do
{ scanf("%s", str);
for (i=0; i if ( (2) )
{ printf("%8s\n", stu[i].name);
printf("%3d\n", stu[i].rank);
printf("%5.1f\n", stu[i].score);
break;
}
if ((i>=NUM)&& strcmp( str,"0") != 0)
printf("not found\n");
} while (strcmp( (3) ) != 0);
return 0;
}
#include
#include
#define NUM 4
struct student
{ int rank;
char *name;
float score;
};
(1) stu[ ] = { 3, "liming", 89.0, 4, "zhanghua",78.2,
1, "wangming", 90.6, 2, "liqing", 96.2 };
int main(void)
{ char str[10];
int i;
do
{ scanf("%s", str);
for (i=0; i
{ printf("%8s\n", stu[i].name);
printf("%3d\n", stu[i].rank);
printf("%5.1f\n", stu[i].score);
break;
}
if ((i>=NUM)&& strcmp( str,"0") != 0)
printf("not found\n");
} while (strcmp( (3) ) != 0);
return 0;
}