解题思路:
1.利用结构体储存学生信息
2.利用malloc 申请内存空间
3.利用指针people 遍历内存信息并输出
注意事项:
用getchar()去除' \n '
参考代码:
#include<stdio.h>
#include<malloc.h>
typedef struct _Student
{
char num[10];
char name[10];
int Chinese;
int Maths;
int English;
}Student;
int main()
{
int n = 0;
scanf("%d", &n);
Student* people = (Student*)malloc(sizeof(Student) * n);
for (int i = 0; i < n; i++)
{
scanf("%s %s %d %d %d", (people+i)->num, (people + i)->name, &(people + i)->Chinese, &(people + i)->Maths, &(people + i)->English);
getchar();
}
for (int i = 0; i < n; i++)
{
printf("%s,%s,%d,%d,%d\n", (people + i)->num, (people + i)->name, (people + i)->Chinese, (people + i)->Maths, (people + i)->English);
}
free(people);
return 0;
}
0.0分
3 人评分
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:1885 |
C语言程序设计教程(第三版)课后习题8.4 (Java代码)浏览:733 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:535 |
哥德巴赫曾猜测 (C语言代码)浏览:1018 |
简单的a+b (C++语言代码)浏览:860 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:647 |
C语言程序设计教程(第三版)课后习题9.10 (C语言代码)浏览:557 |
求圆的面积 (C语言代码)浏览:1670 |
演讲大赛评分 (C语言代码)浏览:1638 |
整除问题 (C语言代码)浏览:526 |