#include
#include
#include
typedef struct Info
{
int num;
char name[21];
float score[3];
}DATA;
void print(DATA *SInfo,int n)
{
int i;
printf("%-4s%-21s%8s%8s%8s\n","num","name","score1","score2","score3");
for(i=0;i
printf("%-4d%-21s%8.1f%8.1f%8.1f\n",SInfo[i].num,SInfo[i].name,SInfo[i].score[0],SInfo[i].score[1],SInfo[i].score[2]);
}
}
void input(DATA *SInfo)
{
int i;
printf("Please Input 5 student Info !\n");
for(i=0;i<5;i++)
{
printf("Please Input the %d student Info:",i+1);
printf("\nPlease Input the num:");
scanf("%d",&SInfo[i].num);
fflush(stdin);
printf("Please Input the name:");
scanf("%s",SInfo[i].name);
fflush(stdin);
printf("Please Input the score:");
scanf("%f%f%f",&SInfo[i].score[0],&SInfo[i].score[1],&SInfo[i].score[2]);
fflush(stdin);
}
}
void main()
{
DATA StuInfo[5];/*={{1,"张三",86,95,96},
{2,"李四",95,86,87},
{3,"王五",89,78,83},
{4,"赵六",73,32,68},
{5,"马七",66,77,88}};*/
int n;
input(StuInfo);
n=sizeof(StuInfo)/sizeof(DATA);
while(StuInfo[n].name[0]!='\0')
{
n++;
}
print(StuInfo,n);
getch();
}