71.编写input()和output()函数的输入,输出5个学生的数据记录
作者:互联网
#include <stdio.h>
#define N 5
struct student{
char num[6];
char name[8];
int score;
}stu[N];
input(struct student stu[]){
for(int i=0;i<N;i++){
printf("please input %d\n",i+1);
printf("num is\n");
scanf("%s",&stu[i].num);
printf("name is\n");
scanf("%s",&stu[i].name);
printf("score is\n");
scanf("%d",&stu[i].score);
}
}
output(struct student stu[]){
for(int i=0;i<N;i++){
printf("num:%s ",stu[i].num);
printf("name:%s ",stu[i].name);
printf("score:%d ",stu[i].score);
printf("\n");
}
}
int main()
{
//传入结构数组stu
input(stu);
output(stu);
}
本题相当于是复习了类的一些操作,结构数组是在类的后面直接定义的
标签:input,int,stu,num,71,printf,output,score,name 来源: https://blog.csdn.net/weixin_43898670/article/details/122707819