#include
#include
struct student
{
int age;
char name[40];
float score;
};
void intput(struct student **st, int len);
void output(struct student **st, int len);
int main (void)
{
int len;
printf("请输入学生人数:");
scanf("%d", &len);
struct student * st = (struct student*)malloc(sizeof(struct student) * len);
intput(&st, len);
output(&st, len);
return 0;
}
void intput(struct student **st, int len)
{
int i;
for (i=0; i
{
printf("请输入第%d个人的姓名:", i+1);
scanf("%s", &st[i]->name);
printf("请输入第%d个人的年龄:", i+1);
scanf("%d", &st[i]->age);
printf("请输入第%d个人的分数:", i+1);
scanf("%f", &st[i]->score);
}
}
void output(struct student **st, int len)
{
int i;
for (i=0; i
{
printf("第%d个人的信息:\n", i+1);
printf("姓名:%s\n", st[i]->name);
printf("年龄:%d\n", st[i]->age);
printf("分数:%f\n", st[i]->score);
}
}