22.编写一个print函数,打印一个学生的成绩数组,该数组中有5个学生的记录,每个记录包括num,name,score[3],用主函数输入这些记录,用print函数输出这些记录。#include"stdio.h"
#define N 5
struct student
char num[6];
char name[8];
int score[4];
jstu[N];
void print(struct student stu(l)
int i.j;
printf("\nNO.name scorel score2 score3\n");
for(i=0;i<N;i++)
printf("%s %s",stu[i].num,stu[i].name);
for(j=0;j<3;j++)
printf("%-9d",stu[i].score(i]);
printf("\n");
void main()
int ij;
printf(“please enter information of students:\n”);
for(i=0;i<N;i++)
printf(“input the %dth studnet:In”,i+1);
printf(“NO.:”);
scanf("%s",stu[i].num);
printf(“Name:”);
scanf("%s",stu[i].name);
for(j=0;j<3;j++)
printf(“score%d:”,j+1);
scanf("%d",&stu[i].scorelj]);
printf("\n");
print(stu);
}
22.编写一个print函数,打印一个学生的成绩数组,该数组中有5个学生的记录,每个记录包括num,name,score[3],用主函数输入这些记录,用print函数输出这些记录。
最新推荐文章于 2024-04-22 21:52:01 发布