#include<stdio.h>
#include<stdlib.h>
#define N 5
struct student
{
char num[6];
char name[4];
int score[4];
}stu[N];
void input(struct student stu[])
{
for (int i = 0; i < N; i++)
{
printf("\n Please input %d of %d\n", i + 1, N);
printf("num:");
scanf("%s", stu[i].num);
printf("name:");
scanf("%s", stu[i].name);
for (int j = 0; j < 3; j++)
{
printf("score%d:", j + 1);
scanf("%d", &stu[i].score[j]);
}
printf("\n");
}
}
void output(struct student stu[])
{
printf("\n No. Name Sco1 Sco2 Sco3\n");
for (int i = 0; i < N; i++)
{
printf("%-6s%-10s", stu[i].num, stu[i].name);
for (int j = 0; j < 3; j++)
{
printf("%-8d", stu[i].score[j]);
}
printf("\n");
}
}
int main()
{
input(stu);
output(stu);
system("pause");
return 0;
}
还没有评论,来说两句吧...