前言:
当前兄弟们对“c语言课程设计学生成绩管理系统源代码”都比较讲究,我们都需要学习一些“c语言课程设计学生成绩管理系统源代码”的相关资讯。那么小编也在网络上网罗了一些关于“c语言课程设计学生成绩管理系统源代码””的相关知识,希望朋友们能喜欢,朋友们一起来学习一下吧!1.题目与要求
1.1问题提出
设计学生成绩管理系统,有N个学生,每个学生的数据包含姓名、年龄、编号和籍贯,试设计一学生管理系统
1.2本系统涉及的知识点
C语言文件操作、数组、函数、链表、头插法、尾插法等等
1.3 功能要求
1、学生信息录入:输入学生的姓名、年龄、编号和籍贯;
2、信息查询:(至少一种查询方式)。按编号查询学生记录,或查询同名学生的记录;
3、信息修改与删除:能够对学生的信息进行一定的修改和删除,存入表单。
4、退出系统:退出整个系统(即主菜单);
1.4 根据所选菜单编写相应代码(略)
1.5 功能效果图(以代码实际效果为准)
二、管理系统源码与注释展示
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>struct MM{char name[20];int age;int num;char addr[20];};//只需要修改和数据有关东西struct Node{//int data;struct MM data;struct Node* next;};struct Node* list = NULL;//1.创建表头:描述最初状态struct Node* createList(){//创建链表就是创建表头//创建表头就是创建结构体变量struct Node* headNode = (struct Node*)malloc(sizeof(struct Node));//表头不给数据初始化headNode->next = NULL;return headNode;}//2.创建节点,为插入做准备:把数据加工成节点struct Node* createNode(struct MM data){struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));newNode->data = data;newNode->next = NULL;return newNode;}//3.表头法插入void insertByHead(struct Node* headNode, struct MM data){//插入之前首先要创建节点struct Node* newNode = createNode(data);newNode->next = headNode->next;headNode->next = newNode;}void deleteAppoinByName(struct Node* headNode, char *name){//相邻的两个指针struct Node* posFrontNode = headNode;struct Node* posNode = headNode->next;//找指定位置while (posNode != NULL&&strcmp(posNode->data.name, name)){posFrontNode = posNode;//下面两句一样的功能posNode = posFrontNode->next;//posNode=posNode->next}//分析查找的结果//循环退出有两种情况:posNode==NULL ,posNode->data==posData;if (posNode == NULL){printf("未找到指定无法删除!\n");return;}else //posNode->data==posData;{posFrontNode->next = posNode->next;free(posNode);posNode = NULL;}}void deleteAppoinByAge(struct Node* headNode, int age){//相邻的两个指针struct Node* posFrontNode = headNode;struct Node* posNode = headNode->next;//找指定位置while (posNode != NULL&&posNode->data.age != age){posFrontNode = posNode;//下面两句一样的功能posNode = posFrontNode->next;//posNode=posNode->next}//分析查找的结果//循环退出有两种情况:posNode==NULL ,posNode->data==posData;if (posNode == NULL){printf("未找到指定无法删除!\n");return;}else //posNode->data==posData;{posFrontNode->next = posNode->next;free(posNode);posNode = NULL;}}//查找函数struct Node* searchByName(struct Node* headNode, char *name){struct Node* pMove = headNode;while (pMove != NULL&&strcmp(pMove->data.name, name)){pMove = pMove->next;}return pMove;}struct Node* searchByAge(struct Node* headNode, int age){struct Node* pMove = headNode;while (pMove != NULL&&pMove->data.age != age){pMove = pMove->next;}return pMove;}void printList(struct Node* headNode){struct Node* pMove = headNode->next; //因为有表头,所以打印是表头的下一个开始打印printf("姓名\t年龄\t编号\t籍贯\n");while (pMove != NULL){//printf("%d\t", pMove->data);printf("%s\t%d\t%d\t%s\n", pMove->data.name, pMove->data.age,pMove->data.num, pMove->data.addr);pMove = pMove->next;}printf("\n"); //调整打印结果}//打印所有相同名字的信息void printListName(struct Node* headNode,char *name){struct Node* pMove = headNode->next; //因为有表头,所以打印是表头的下一个开始打印printf("姓名\t年龄\t编号\t籍贯\n");while (pMove != NULL){//printf("%d\t", pMove->data);if (strcmp(pMove->data.name,name)==0)printf("%s\t%d\t%d\t%s\n", pMove->data.name, pMove->data.age,pMove->data.num, pMove->data.addr);pMove = pMove->next;}printf("\n"); //调整打印结果}//特殊需求需要写特殊代码//删除功能:删除所有相同姓名的人void deleteByName(struct Node* headNode, char *name){while (searchByName(headNode, name) != NULL){deleteAppoinByName(headNode, name);}}void deleteByAge(struct Node* headNode, int age){while (searchByAge(headNode, age) != NULL){deleteAppoinByAge(headNode, age);}}//文件操作//读操作void readInfoFromFile(struct Node* headNode, char *fileName){FILE *fp = fopen(fileName, "r");if (fp == NULL){fp = fopen(fileName, "w+");}struct MM info;while (fscanf(fp, "%s\t%d\t%d\t%s\n", info.name, &info.age, &info.num, info.addr) != EOF){insertByHead(headNode, info);}fclose(fp);}//写操作void saveInfoToFile(struct Node* headNode, char *fileName){FILE *fp = fopen(fileName, "w");struct Node* pMove = headNode->next;while (pMove != NULL){fprintf(fp, "%s\t%d\t%d\t%s\n", pMove->data.name, pMove->data.age,pMove->data.num, pMove->data.addr);pMove = pMove->next;}fclose(fp);}void menu(){printf("---------【学生管理系统】----------\n");printf("\t0.退出系统!\n");printf("\t1.登记学生信息!\n");printf("\t2.浏览学生信息!\n");printf("\t3.查找学生信息!\n");printf("\t4.封印学生信息!\n");printf("\t5.修改学生信息\n");printf("\t6.删除所有相同姓名的学生信息\n");printf("----------------------------------\n");printf("请输入(0~5):");}void keyDown(){int choice = 0;struct MM data;struct Node* result = NULL;scanf("%d", &choice);switch (choice){case 0:printf("退出成功!\n");system("pause");exit(0);break;case 1:printf("请输入(name,age,num,addr):");scanf("%s%d%d%s", data.name, &data.age, &data.num, data.addr);insertByHead(list, data);saveInfoToFile(list, "1.txt");break;case 2:printList(list);break;case 3:printf("请输入要查询的学生的姓名:");scanf("%s", data.name);result = searchByName(list, data.name);if (result == NULL){printf("未找到相关信息!\n");}else{printf("姓名\t年龄\t编号\t籍贯\n");printf("%s\t%d\t%d\t%s\n", result->data.name, result->data.age,result->data.num, result->data.addr);}break;case 4:printf("请输入要封印的学生信息:");scanf("%s", data.name);deleteAppoinByName(list, data.name);saveInfoToFile(list, "1.txt");break;case 5:printf("请输入要修改的学生的姓名:");scanf("%s", data.name);result = searchByName(list, data.name);if (result == NULL){printf("未找到相关信息!,无法修改\n");}else{printf("请输入新的信息(name,age,num,addr):");scanf("%s%d%d%s", result->data.name, &result->data.age,&result->data.num, result->data.addr);printf("修改成功!\n");saveInfoToFile(list, "1.txt");}break;case 6:printf("请输入要删除的学生的姓名:");scanf("%s", data.name);deleteByName(list, data.name);saveInfoToFile(list, "1.txt");break;default:printf("输入错误!\n");break;}}int main(){list = createList();readInfoFromFile(list, "1.txt");while (1){menu();keyDown();system("pause");system("cls");}system("pause");return 0;}
本次的分享就到这里了!源码大家可以直接复制获取~不过可能会因为编译原因导致乱码,建议大家重新写一遍,也可以加深自己的学习映像!如果大家在学习C语言C++的时候有什么学习上的问题的话,可以来和我一起↓↓↓交流学习哦~
编程学习书籍分享:
编程学习视频分享:
另外,对我们来说还是学编程最重要!栽一棵树最好的时间是十年前,其次是现在。对于准备学习编程的小伙伴,如果你想更好地提升你的编程核心能力(内功)不妨从现在开始!
整理分享(多年学习的源码、项目实战视频、项目笔记,基础入门教程)
欢迎转行和学习编程的伙伴,利用更多的资料学习成长比自己琢磨更快哦!
点击下方【了解更多】获取更多学习资料帮助你学习成长哦~
标签: #c语言课程设计学生成绩管理系统源代码 #c语言简单管理系统代码 #c语言期末试题 #c语言源代码作业 #c语言程序设计作业2