C语言学生管理系统代码

时间: 2023-12-20 15:30:53 浏览: 36
C语言学生管理系统代码是一个用C语言编写的程序,用于管理学生信息和成绩。以下是一个简单的C语言学生管理系统代码示例: ```c #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_STUDENT_NUM 100 struct student { char name[20]; int id; float score; }; struct student students[MAX_STUDENT_NUM]; int student_num = 0; void add_student() { if (student_num >= MAX_STUDENT_NUM) { printf("Error: student list is full.\n"); return; } struct student new_student; printf("Please enter the name of the student: "); scanf("%s", new_student.name); printf("Please enter the ID of the student: "); scanf("%d", &new_student.id); printf("Please enter the score of the student: "); scanf("%f", &new_student.score); students[student_num] = new_student; student_num++; printf("Student added successfully.\n"); } void print_student(struct student s) { printf("Name: %s, ID: %d, Score: %.2f\n", s.name, s.id, s.score); } void print_all_students() { if (student_num == 0) { printf("No students found.\n"); return; } printf("All students:\n"); for (int i = 0; i < student_num; i++) { print_student(students[i]); } } void search_student() { if (student_num == 0) { printf("No students found.\n"); return; } int search_id; printf("Please enter the ID of the student you want to search: "); scanf("%d", &search_id); for (int i = 0; i < student_num; i++) { if (students[i].id == search_id) { print_student(students[i]); return; } } printf("No student found with ID %d.\n", search_id); } void delete_student() { if (student_num == 0) { printf("No students found.\n"); return; } int delete_id; printf("Please enter the ID of the student you want to delete: "); scanf("%d", &delete_id); for (int i = 0; i < student_num; i++) { if (students[i].id == delete_id) { for (int j = i; j < student_num - 1; j++) { students[j] = students[j + 1]; } student_num--; printf("Student deleted successfully.\n"); return; } } printf("No student found with ID %d.\n", delete_id); } int main() { int choice; while (1) { printf("**************************\n"); printf("**\t学生管理系统\t**\n"); printf("**************************\n"); printf("**\t1.录入学生信息\t**\n"); printf("**\t2.查找学生信息\t**\n"); printf("**\t3.删除学生信息\t**\n"); printf("**\t4.显示所有学生\t**\n"); printf("**\t0.退出系统\t**\n"); printf("**************************\n"); printf("Please enter your choice: "); scanf("%d", &choice); switch (choice) { case 1: add_student(); break; case 2: search_student(); break; case 3: delete_student(); break; case 4: print_all_students(); break; case 0: printf("Goodbye!\n"); exit(0); default: printf("Invalid choice.\n"); break; } } return 0; } ``` 该程序包含以下功能: 1.录入学生信息 2.查找学生信息 3.删除学生信息 4.显示所有学生 用户可以根据自己的需要选择相应的功能。该程序使用结构体存储学生信息,可以存储最多100个学生的信息。

相关推荐

最新推荐

recommend-type

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

本文实例为大家分享了C语言实现学生学籍管理系统的具体代码,供大家参考,具体内容如下 #include #include #include #include #define N 100 /*存储100个学生的学籍信息*/ int flag; /*标记是否登录*/ struct date...
recommend-type

C语言编写教务管理系统

C语言编写教务管理系统
recommend-type

C语言学生信息管理系统(有源代码)

老师布置的假期作业,我感觉我写的还算很好的,没日没夜的写了一周左右吧。 第一次上传资源(不知道一积分算不算多),欢迎下载。
recommend-type

C语言实现班档案管理系统课程设计

主要为大家详细介绍了C语言实现班档案管理系统课程设计,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
recommend-type

学籍管理系统源代码 c++.docx

为了学校更加高效,快捷,方便的管理学生信息,并实现以下功能: (1)对学生信息进行录入:先输入学生的学籍,然后输入学生姓名,年龄,性别,籍贯,系别,专业,班级等,最后输入学生状态(入学)。 (2)对已录取...
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开根号的最新研究和应用:获取开根号领域的最新动态

![matlab开根号](https://www.mathworks.com/discovery/image-segmentation/_jcr_content/mainParsys3/discoverysubsection_1185333930/mainParsys3/image_copy.adapt.full.medium.jpg/1712813808277.jpg) # 1. MATLAB开根号的理论基础 开根号运算在数学和科学计算中无处不在。在MATLAB中,开根号可以通过多种函数实现,包括`sqrt()`和`nthroot()`。`sqrt()`函数用于计算正实数的平方根,而`nt
recommend-type

react的函数组件的使用

React 的函数组件是一种简单的组件类型,用于定义无状态或者只读组件。 它们通常接受一个 props 对象作为参数并返回一个 React 元素。 函数组件的优点是代码简洁、易于测试和重用,并且它们使 React 应用程序的性能更加出色。 您可以使用函数组件来呈现简单的 UI 组件,例如按钮、菜单、标签或其他部件。 您还可以将它们与 React 中的其他组件类型(如类组件或 Hooks)结合使用,以实现更复杂的 UI 交互和功能。
recommend-type

JSBSim Reference Manual

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