SHAOXIAOJ正在加载中...

1209: 【实验9.1.2 结构体程序设计】

金币值:2 定数:6 时间限制:1.000 s 内存限制:128 M
正确:8 提交:10 正确率:80.00% 命题人:
点赞量:0 收藏量:0 题目类型:程序 知识点: 结构体

题目描述

下列程序的功能是统计及格学生的人数并输出及格学生的信息。修改程序,保证运行正确。

#include <stdio.h>

struct student

{  int num;              //学号

   char name[12];         //姓名

   int score;            //成绩

};

int main(void)

{

student stud[6]={ {1001,"Pan Dong",48},             /*$ERROR$*/

                          {1002,"Zhao Hua",62},

                          {1003,"Hu Litai",93},

                          {1004,"Zhang Li",85},

                          {1005,"Liu Ming",58},

                          {1006,"Xin Peng",37}};

int i,n=0;

printf("num\tname\t\tscore\n");

i=0;

while(i<6)

{

if(score>=60)                                       /*$ERROR$*/

{

printf("%d\t%s\t%d\n",stud[i].num,stud[i].name,stud[i].score);

     n--;                                              /*$ERROR$*/

}

   i++;

  }

printf("n=%d\n",n);

return 0;

}



输出样例    复制

num	name		score
1002	Zhao Hua	62
1003	Hu Litai	93
1004	Zhang Li	85
n=3

提示

如果是运行环境是C++,则 本行 student stud[6]={ {1001,"Pan Dong",48},             /*$ERROR$*/  没有错误;
如果是C环境,则本行 student stud[6]={ {1001,"Pan Dong",48},             /*$ERROR$*/   有错误