* 1。根据学生信息定义一个结构体类型,再说明一个该结构体类型的数组。*/
struct stu_info{
char stuNo[10];/* No */
char stuName[30];/* Name */
float stuScore[3];/* the three scores */
float aveScore; /* average score */
float totalScore; /* total score */
}stu[10];
/* 2。用input函数从键盘上输入10个学生的数据。 */
void input()
{ int i = 0;
printf("Input the students' infomation(FORMAT LIKE:No Name score1 score2 score3):\n");
while(i < 10)
{ printf("Input %d:",i + 1);
scanf("%s%s%f%f%f",stu[i].stuNo,stu[i].stuName,&stu[i].stuScore[0],&stu[i].stuScore[1],&stu[i].stuScore[2]);
i++;
}
}
追问如果我要输入100个学生的信息要怎么做?
追答使用malloc函数,
要包含头文件 #include
追问额 看不懂... 您能打出来吗?我想输入的是N个学生,然后这个N可以由用户设定的那种,要怎么做?