#include <stdio.h>
#define N 3
struct student
{
int num;
char name[20];
int score[3];
}stu1[3];
int main()
{
void print(struct student stu1[N]);
void input(struct student stu1[N]);
input(stu1);
print(stu1);
return 0;
}
void input(struct student stu1[N])
{
int i,j;
for(i=0;i<N;i++)
{
printf("input %dth student info:\n",i+1);
printf("NO.:");
scanf("%d",&stu1[i].num);
printf("name:");
scanf("%s",stu1[i].name);
for(j=0;j<N;j++)
{
printf("%dscore:",j+1);
scanf("%d",&stu1[i].score[j]);
}
}
}
void print(struct student stu1[N])
{
int i,j;
for(i=0;i<N;i++)
{
printf("%d %s ",stu1[i].num,stu1[i].name);
for(j=0;j<N;j++)
{
printf("%d ",stu1[i].score[j]);
}
printf("\n");
}
}
定义结构体,通过for循环输入输出学生参数
最新推荐文章于 2023-07-24 14:46:32 发布