阅读以上代码,回答问题: (1) 这段代码最终不能在屏幕上输出5个学生的信息,为什么。

#include //行号 1

struct student //2

{ char num[10]; //3

int score[3]; //4

}; //5

void stu_input( int m ) //6

{ int i ,k; //7

struct student stu[20]; //8

printf("input:\n"); //9

for(i=0;i<m;i++){ //10

scanf("%s",stu[i].num); //11

for(k=0;k<3;k++) //12

scanf("%d",&stu[i].score[k]); //13

} //14

} //15

int main() //16

{ int i,k,m; //17

struct student stu[20]; //18

m=5; //19

add(m); //20

for(i=0;i<m;i++){ //21

printf("\n%s ",stu[i].num); //22

for(k=0;k<3;k++) //23

printf("%5d",stu[i].score[k]); //24

} //25

return 0; } //26

阅读以上代码,回答问题:

(1) 这段代码最终不能在屏幕上输出5个学生的信息,为什么?修改代码,使其能在屏幕上输出5个学生的信息

(2) 程序中如何修改可以保存50个学生信息?

(3) 如果需要增加学生的信息:性别,如何修改代码?

可以用行号说明位置,例如:第3行是变量定义

  1. 第8行声明的stu[20]是局部变量,对他的输入,不能改变main函数中第18行声明的局部变量stu[20]。删掉第8行和第18行;第5行修改为}stu[20]; 2.stu[50] 3.第4行后插入语句 char sex;