第1个回答 推荐于2016-09-27
#include<stdio.h>
struct men
{
int num;
char name[8];
char sex[8];
float score;
}boy[5];
void input()
{
int i;
for(i=0;i<5;i++)
{
printf("Input the number:\n");
scanf("%d",&boy[i].num);
printf("Input the name:\n");
scanf("%s",boy[i].name);
printf("Input the sex:\n");
scanf("%s",boy[i].sex);
printf("Input the score:\n");
scanf("%f",&boy[i].score);
}
}
void output()
{
int i;
for(i=0;i<5;i++)
{
printf("NUM\t\t\tNAME\t\t\tSEX\t\t\tSCORE\n");
printf("%d\t\t\t",boy[i].num);
printf("%s\t\t\t",boy[i].name);
printf("%c\t\t\t",boy[i].sex);
printf("%.2f\n\n",boy[i].score);
}
}
int main()
{
void input();
void output();
input();
output();
return (0);
}本回答被提问者采纳
第2个回答 2012-05-21
struct student
{
int num;
char name[20];
float score[3];
}stu[5];
void input(struct student stu[5])
{
int i,j;
for(i=0;i<5;i++)
{
scanf("%d,%s",&stu[i].num,&stu[i].name);
for(j=0;j<3;j++)
scanf("%f",&stu[i].score[j]);
}
}
void output(struct student stu[5])
{
int i,j;
for(i=0;i<5;i++)
{
printf("%d,%s,",stu[i].num,stu[i].name);
for(j=0;j<3;j++)
printf("%.2f,",stu[i].score[j]);
printf("\n");
}
}
main()
{
input(stu);
output(stu);
}