那你可以用c语言编写一个学生成绩管理系统吗 有数学 语文 英语 ,可以求每个学生的和,可以删除添加学生, 求最高分

时间: 2024-03-23 18:41:20 浏览: 14
是的,我可以用C语言编写一个学生成绩管理系统。下面是一个简单的实现,可以实现添加学生、删除学生、计算每个学生的总分、计算每个科目的最高分等功能。 ```c #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_NAME_LEN 20 #define MAX_STUDENT_NUM 100 typedef struct student { char name[MAX_NAME_LEN]; int math_score; int chinese_score; int english_score; } Student; Student students[MAX_STUDENT_NUM]; int student_count = 0; void add_student() { if (student_count >= MAX_STUDENT_NUM) { printf("Too many students!\n"); return; } Student new_student; printf("Please enter the name of the student: "); scanf("%s", new_student.name); printf("Please enter the math score of the student: "); scanf("%d", &new_student.math_score); printf("Please enter the Chinese score of the student: "); scanf("%d", &new_student.chinese_score); printf("Please enter the English score of the student: "); scanf("%d", &new_student.english_score); students[student_count++] = new_student; printf("Student added successfully!\n"); } void delete_student() { char name[MAX_NAME_LEN]; printf("Please enter the name of the student you want to delete: "); scanf("%s", name); int found = 0; for (int i = 0; i < student_count; i++) { if (strcmp(students[i].name, name) == 0) { found = 1; for (int j = i; j < student_count - 1; j++) { students[j] = students[j + 1]; } student_count--; printf("Student deleted successfully!\n"); break; } } if (!found) { printf("Student not found!\n"); } } void print_student(Student student) { printf("%-10s%-10d%-10d%-10d\n", student.name, student.math_score, student.chinese_score, student.english_score); } void print_all_students() { printf("%-10s%-10s%-10s%-10s\n", "Name", "Math", "Chinese", "English"); for (int i = 0; i < student_count; i++) { print_student(students[i]); } } int get_total_score(Student student) { return student.math_score + student.chinese_score + student.english_score; } void calculate_total_score() { printf("%-10s%-10s\n", "Name", "Total"); for (int i = 0; i < student_count; i++) { printf("%-10s%-10d\n", students[i].name, get_total_score(students[i])); } } int get_max_score(int (*get_score)(Student)) { int max_score = -1; for (int i = 0; i < student_count; i++) { int score = get_score(students[i]); if (score > max_score) { max_score = score; } } return max_score; } void calculate_max_score() { printf("%-10s%-10d\n", "Math", get_max_score(&((int (*)(Student))get_total_score)))); printf("%-10s%-10d\n", "Chinese", get_max_score(&((int (*)(Student))&students[0].chinese_score)))); printf("%-10s%-10d\n", "English", get_max_score(&((int (*)(Student))&students[0].english_score)))); } int main() { while (1) { printf("\n"); printf("1. Add student\n"); printf("2. Delete student\n"); printf("3. Print all students\n"); printf("4. Calculate total score\n"); printf("5. Calculate max score\n"); printf("6. Exit\n"); printf("Please enter your choice: "); int choice; scanf("%d", &choice); switch (choice) { case 1: add_student(); break; case 2: delete_student(); break; case 3: print_all_students(); break; case 4: calculate_total_score(); break; case 5: calculate_max_score(); break; case 6: exit(0); default: printf("Invalid choice!\n"); } } return 0; } ``` 注意,这只是一个简单的实现,可能存在一些不足和漏洞。如果您需要更为完善的学生成绩管理系统,建议您根据自己的需求进行定制化开发。

最新推荐

recommend-type

学生成绩管理系统(数据结构)实验报告.docx

期末实践周必备(数据结构)学生成绩管理系统,基于C语言完成的,百分百作者原创,资源保证!
recommend-type

C语言实现简单学生学籍管理系统

主要为大家详细介绍了C语言实现简单学生学籍管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
recommend-type

C语言实现简单学生选课管理系统

主要为大家详细介绍了C语言实现简单学生选课管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
recommend-type

c语言作业——学生成绩统计.docx

(3)统计学生成绩分布情况(每个分数段人数); (4)查找最高分、最低分;计算学生成绩均值和方差;并输出这四个结果; (5)判断成绩是否服从正态分布; (6)统计不同生源地学生的平均成绩,按平均成绩排序,并...
recommend-type

C语言数组实现学生信息管理系统设计

主要为大家详细介绍了C语言数组实现学生信息管理系统设计,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

【实战演练】MATLAB用遗传算法改进粒子群GA-PSO算法

![MATLAB智能算法合集](https://static.fuxi.netease.com/fuxi-official/web/20221101/83f465753fd49c41536a5640367d4340.jpg) # 2.1 遗传算法的原理和实现 遗传算法(GA)是一种受生物进化过程启发的优化算法。它通过模拟自然选择和遗传机制来搜索最优解。 **2.1.1 遗传算法的编码和解码** 编码是将问题空间中的解表示为二进制字符串或其他数据结构的过程。解码是将编码的解转换为问题空间中的实际解的过程。常见的编码方法包括二进制编码、实数编码和树形编码。 **2.1.2 遗传算法的交叉和
recommend-type

openstack的20种接口有哪些

以下是OpenStack的20种API接口: 1. Identity (Keystone) API 2. Compute (Nova) API 3. Networking (Neutron) API 4. Block Storage (Cinder) API 5. Object Storage (Swift) API 6. Image (Glance) API 7. Telemetry (Ceilometer) API 8. Orchestration (Heat) API 9. Database (Trove) API 10. Bare Metal (Ironic) API 11. DNS
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。