#include <stdio.h>
#define N 5
struct student
{char num;
char name[10];
int score[3];
}stu[N];
input(struct student stu[])
{int m,k;
for(m=0;m<N;m++)
{printf("please input scores of student %d:\n",m+1);
printf("NO.:");
scanf("%d",&stu[m].num);
printf("name:");
scanf("%s",stu[m].name);
for(k=0;k<3;k++)
{printf("score %d:",k+1);
scanf("%d",&stu[m].score[k]);
}
}
}
void print(struct student stu[])
{ int i,j;
for(i=0;i<N;i++)
{printf("%d,%s",stu[i].num,stu[i].name);
{for(j=0;j<3;j++)
printf(" %d ",stu[i].score[j]);}printf("\n");}
}
main()
{
int i,j;
struct student stu[N];
printf("please input the records:\n");
for(i=0;i<N;i++) //不需要的循环,你把N赋为2,就输四次,重赋值了一次
input(stu);
print(stu);
getch();
}
#define N 5
struct student
{char num;
char name[10];
int score[3];
}stu[N];
input(struct student stu[])
{int m,k;
for(m=0;m<N;m++)
{printf("please input scores of student %d:\n",m+1);
printf("NO.:");
scanf("%d",&stu[m].num);
printf("name:");
scanf("%s",stu[m].name);
for(k=0;k<3;k++)
{printf("score %d:",k+1);
scanf("%d",&stu[m].score[k]);
}
}
}
void print(struct student stu[])
{ int i,j;
for(i=0;i<N;i++)
{printf("%d,%s",stu[i].num,stu[i].name);
{for(j=0;j<3;j++)
printf(" %d ",stu[i].score[j]);}printf("\n");}
}
main()
{
int i,j;
struct student stu[N];
printf("please input the records:\n");
for(i=0;i<N;i++) //不需要的循环,你把N赋为2,就输四次,重赋值了一次
input(stu);
print(stu);
getch();
}