用c语言编写学生成绩管理实现功能:输入、输出、插入、删除、查找、追加、读入、显示、保存、拷贝、排序、索引、分类合计、退出。

时间: 2024-01-13 12:03:56 浏览: 72
以下是用C语言编写学生成绩管理实现各种功能的示例代码: 1. 输入学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void inputScore(struct Student *student) { printf("请输入学生的成绩:\n"); printf("大学英语成绩:"); scanf("%f", &(student->english)); printf("毛概成绩:"); scanf("%f", &(student->politics)); printf("数据结构成绩:"); scanf("%f", &(student->dataStructure)); printf("数据库成绩:"); scanf("%f", &(student->database)); } ``` 2. 输出学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void outputScore(struct Student student) { printf("学生的成绩如下:\n"); printf("大学英语成绩:%f\n", student.english); printf("毛概成绩:%f\n", student.politics); printf("数据结构成绩:%f\n", student.dataStructure); printf("数据库成绩:%f\n", student.database); } ``` 3. 插入学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void insertScore(struct Student *student, float english, float politics, float dataStructure, float database) { student->english = english; student->politics = politics; student->dataStructure = dataStructure; student->database = database; } ``` 4. 删除学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void deleteScore(struct Student *student) { student->english = 0; student->politics = 0; student->dataStructure = 0; student->database = 0; } ``` 5. 查找学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void searchScore(struct Student student) { printf("学生的成绩如下:\n"); printf("大学英语成绩:%f\n", student.english); printf("毛概成绩:%f\n", student.politics); printf("数据结构成绩:%f\n", student.dataStructure); printf("数据库成绩:%f\n", student.database); } ``` 6. 追加学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void appendScore(struct Student *student, float english, float politics, float dataStructure, float database) { student->english += english; student->politics += politics; student->dataStructure += dataStructure; student->database += database; } ``` 7. 读入学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void readScore(struct Student *student) { printf("请输入学生的成绩:\n"); printf("大学英语成绩:"); scanf("%f", &(student->english)); printf("毛概成绩:"); scanf("%f", &(student->politics)); printf("数据结构成绩:"); scanf("%f", &(student->dataStructure)); printf("数据库成绩:"); scanf("%f", &(student->database)); } ``` 8. 显示学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void displayScore(struct Student student) { printf("学生的成绩如下:\n"); printf("大学英语成绩:%f\n", student.english); printf("毛概成绩:%f\n", student.politics); printf("数据结构成绩:%f\n", student.dataStructure); printf("数据库成绩:%f\n", student.database); } ``` 9. 保存学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void saveScore(struct Student student) { FILE *file = fopen("score.txt", "w"); if (file == NULL) { printf("保存失败!\n"); return; } fprintf(file, "大学英语成绩:%f\n", student.english); fprintf(file, "毛概成绩:%f\n", student.politics); fprintf(file, "数据结构成绩:%f\n", student.dataStructure); fprintf(file, "数据库成绩:%f\n", student.database); fclose(file); printf("保存成功!\n"); } ``` 10. 拷贝学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void copyScore(struct Student *dest, struct Student src) { dest->english = src.english; dest->politics = src.politics; dest->dataStructure = src.dataStructure; dest->database = src.database; } ``` 11. 排序学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void sortScore(struct Student *students, int count) { // 使用冒泡排序按照大学英语成绩从小到大排序 for (int i = 0; i < count - 1; i++) { for (int j = 0; j < count - i - 1; j++) { if (students[j].english > students[j + 1].english) { struct Student temp = students[j]; students[j] = students[j + 1]; students[j + 1] = temp; } } } } ``` 12. 索引学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void indexScore(struct Student *students, int count) { printf("学生成绩索引如下:\n"); for (int i = 0; i < count; i++) { printf("学生%d的大学英语成绩:%f\n", i + 1, students[i].english); } } ``` 13. 分类合计学生成绩: ```c #include <stdio.h> struct Student { float english; float politics; float dataStructure; float database; }; void sumScore(struct Student *students, int count) { float englishSum = 0; float politicsSum = 0; float dataStructureSum = 0; float databaseSum = 0; for (int i = 0; i < count; i++) { englishSum += students[i].english; politicsSum += students[i].politics; dataStructureSum += students[i].dataStructure; databaseSum += students[i].database; } printf("大学英语成绩总和:%f\n", englishSum); printf("毛概成绩总和:%f\n", politicsSum); printf("数据结构成绩总和:%f\n", dataStructureSum); printf("数据库成绩总和:%f\n", databaseSum); } ``` 14. 退出程序: ```c #include <stdio.h> #include <stdlib.h> void exitProgram() { printf("程序已退出!\n"); exit(0); } ```

相关推荐

最新推荐

recommend-type

C语言实现带头结点的链表的创建、查找、插入、删除操作

主要介绍了C语言实现带头结点的链表的创建、查找、插入、删除操作方法,对于了解数据结构中链表的各项操作有很好的借鉴价值,需要的朋友可以参考下
recommend-type

用C语言实现从文本文件中读取数据后进行排序的功能

是一个十分可靠的程序,这个程序的查错能力非常强悍。程序包含了文件操作,归并排序和字符串输入等多种技术。对大家学习C语言很有帮助,有需要的一起来看看。
recommend-type

C语言程序设计实现学生成绩记录簿

通过编写c语言《学生成绩记录簿系统》让我知道所学的编程语言是需要多练多编写代码锻炼出来的。 1)C语言课程设计的主要目的是培养学生综合运用C语言程序设计课程所学到的知识,编写C程序解决实际问题的能力,以及...
recommend-type

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

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

C语言输入学生成绩,计算并输出这些学生的最低分、最高分、平均分。

输入学生人数n,再输入n个学生的成绩,将所有成绩累加,再除以n,得到平均分;将第一个学生的成绩赋给最大最小值,用第i个分数与最大值比较,若第i个分数&gt;最大值,将第i个分数赋值给最大值,同理得最小值,最后输出...
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

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

解释minorization-maximization (MM) algorithm,并给出matlab代码编写的例子

Minorization-maximization (MM) algorithm是一种常用的优化算法,用于求解非凸问题或含有约束的优化问题。该算法的基本思想是通过构造一个凸下界函数来逼近原问题,然后通过求解凸下界函数的最优解来逼近原问题的最优解。具体步骤如下: 1. 初始化参数 $\theta_0$,设 $k=0$; 2. 构造一个凸下界函数 $Q(\theta|\theta_k)$,使其满足 $Q(\theta_k|\theta_k)=f(\theta_k)$; 3. 求解 $Q(\theta|\theta_k)$ 的最优值 $\theta_{k+1}=\arg\min_\theta Q(
recommend-type

JSBSim Reference Manual

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