|
发表于 2013-1-19 01:59:50
|
显示全部楼层
- #include <stdio.h>
- #include <string.h>
- struct student
- {
- char num[9]; // 你用int类型数组来放一个数,我觉得逻辑不对
- char name[20];
- char sex;
- float jsj_score;
- float yw_score;
- float sx_score;
- float yy_score;
- };
- void main ()
- {
- int i;
- struct student d[10];
- for (i = 0; i < 10; i++)
- {
- fflush(stdin);
- printf ("学号:");
- scanf ("%s",d[i].num);
- printf ("名字:");
- scanf ("%s",d[i].name);
- printf ("性别:");
- scanf ("%s",&d[i].sex);
- printf ("计算机成绩:");
- d[i].jsj_score=0; //scanf对浮点数变量取值有个bug,需要先对浮点数进行赋值。
- scanf ("%f",&d[i].jsj_score);
- printf ("语文成绩:");
- scanf ("%f",&d[i].yw_score);
- printf ("数学成绩:");
- scanf ("%f",&d[i].sx_score);
- printf ("英语成绩:");
- scanf ("%f",&d[i].yy_score);
- }
- }
复制代码
|
|