# include <stdio.h>
# include <malloc.h>
//声明数组结构
struct Student
{
char name[100];
int age;
float sorce;
};
int main(void)
{
int count;
int i;
struct Student *pArr;
printf("输入学生个数\n");
scanf("%d" , &count);
//动态开辟空间
pArr = (struct Student *)malloc(count * sizeof(struct Student));
for(i= 0; i< count ; i++){
printf("输入第%d个学生的信息\n", i+1);
printf("输入姓名=\n");
scanf("%s" , &pArr[i].name);
printf("输入年龄=\n");
scanf("%d" , &pArr[i].age);
printf("输入分数=\n");
scanf("%f" , &pArr[i].sorce);
}
for(i= 0; i< count ; i++){
printf("输入第%d个学生的信息\n", i+1);
printf("姓名=%s,年龄=%d,分数=%f \n", pArr[i].name,pArr[i].age,pArr[i].sorce);
}
return 0;
}
网友评论