生成一个C语言的学生信息统计表
时间: 2024-05-20 09:17:37 浏览: 5
#include <stdio.h>
#include <string.h>
struct student {
char name[50];
int age;
char gender;
float grade;
};
int main() {
int n;
printf("请输入学生人数:");
scanf("%d", &n);
struct student stu[n];
for (int i = 0; i < n; i++) {
printf("请输入第%d个学生的信息:\n", i + 1);
printf("姓名:");
scanf("%s", stu[i].name);
printf("年龄:");
scanf("%d", &stu[i].age);
printf("性别(男/女):");
scanf(" %c", &stu[i].gender);
printf("成绩:");
scanf("%f", &stu[i].grade);
}
printf("\n学生信息如下:\n");
printf("姓名\t年龄\t性别\t成绩\n");
for (int i = 0; i < n; i++) {
printf("%s\t%d\t%c\t%.2f\n", stu[i].name, stu[i].age, stu[i].gender, stu[i].grade);
}
return 0;
}
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)