项目所用数据结构:链表
算法:对链表数据的增删改查操作,冒泡排序
系统架构图:

项目文件结构:

(1)system.h
#ifndef SYSTEM_H_INCLUDED
#define SYSTEM_H_INCLUDED
//宏定义学生信息的一种表示形式
#define STUDENT_DATA  pMove->studentData.studentId,pMove->studentData.name,pMove->studentData.sex,pMove->studentData.age,pMove->studentData.className,pMove->studentData.major,pMove->studentData.tel,pMove->studentData.score#define STUDENT_RANKING stuRanking[j].studentId, stuRanking[j].name, stuRanking[j].className, stuRanking[j].score,stuRanking[j].ranking
struct student
{char studentId[15];  //学号char name[10];char sex[4];int  age;char className[20];  //班级char major[20];  //专业char tel[15];int  score;    //入学成绩
};struct Node
{struct student studentData;struct Node* next;
};struct studentRanking
{char studentId[15];char name[10];char className[20];int  score;int  ranking;};
extern struct Node* studentList;  //链表的头指针
#endif // SYSTEM_H_INCLUDED
(2)main.h
#ifndef MAIN_H_INCLUDED
#define MAIN_H_INCLUDED
#include "AddStudent.h"
#include "BeginingAndEnding.h"
#include "DeleteStudent.h"
#include "ModifyStudent.h"
#include "SearchStudent.h"
#include "ShowStudent.h"
#include "ShowStudentRanking.h"
#include "MyList.h"
#include "system.h"
void showMenu();#endif // MAIN_H_INCLUDED
(3)main.c
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>   //getc函数使用的头文件
#include "main.h"
//主函数
int main()
{int selection;
Int ret;Begining();showMenu();      //展示界面ret = scanf("%d", &selection); //读入用户输入数字
getchar();
While(ret != 1)
{printf(“输入错误,请选择(0-6):”);ret = scanf("%d", &selection); //读入用户输入数字
}while (selection){switch (selection){case 1:AddStudent();  //录入学生信息break;case 2:ShowStudent();  //浏览学生信息break;case 3:SearchStudent(); //查找学生信息break;case 4:DeleteStudent(); //删除学生信息break;case 5:ModifyStudent();//修改学生信息break;case 6:ShowRanking(); //显示学生排名break;default:printf("\t\t请输入正确的数字!\n");}Ending(); //将链表数据写入文件printf("|按任意键返回系统菜单|");getch(); //接收用户输入的任意字符system("cls");showMenu();ret = scanf("%d", &selection); //提示用户输入数字getchar();While(ret != 1)
{printf(“输入错误,请选择(0-6):”);ret = scanf("%d", &selection); //读入用户输入数字
}}return 0;
}void showMenu()
{printf("\n\n\n\n\n");printf("\t|--------------- 欢迎进入 ----------------|\n");printf("\t|             新生入学登记系统            |\n");printf("\t|                 主菜单                  |\n");printf("\t|            1. 录入学生信息              |\n");printf("\t|            2. 浏览学生信息              |\n");printf("\t|            3. 查找学生信息              |\n");printf("\t|            4. 删除学生信息              |\n");printf("\t|            5. 修改学生信息              |\n");printf("\t|            6. 新生入学排名              |\n");printf("\t|            0. 退出系统                  |\n");printf("\t|-----------------------------------------|\n");printf("\n");printf("\t\t请选择(0-6):");
}
(4)BeginingAndEnding.h
#ifndef BEGININGANDENDING_H_INCLUDED
#define BEGININGANDENDING_H_INCLUDED
//关于启动函数和结束函数
void Begining();
void Ending();
#endif // BEGININGANDENDING_H_INCLUDED
(5)BeginingAndEnding.c
#include <stdio.h>
#include <conio.h>   //getc函数使用的头文件
#include "system.h"
#include "AboutFiles.h"
#include "BeginingAndEnding.h"
#include "MyList.h"
void Begining()
{readInfoFromFile("studentList.txt");
}
void Ending()
{writeInfoToFile("studentList.txt");
}
(6)MyList.h
#ifndef MYLIST_H_INCLUDED
#define MYLIST_H_INCLUDED
//关于链表的函数声明
//创建节点
struct Node* createNode(struct student data);
//插入节点
void insertNodeByHead(struct student data);
//指定位置删除节点
void deleteAppointNode(char* studentId);
//查找功能
struct Node* searchInfoByData(char* studentId);
//打印链表
void printList();
#endif // MYLIST_H_INCLUDED
(7)MyList.c
#include <stdio.h>
#include <conio.h>   //getc函数使用的头文件
#include <windows.h> //Sleep函数使用的头文件
#include <string.h>//strcmp函数使用的头文
#include "system.h"
#include "MyList.h"struct Node* studentList = NULL;  //链表的头指针
//创建节点
struct Node* createNode(struct student studentData)
{struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));if(newNode != NULL){newNode->studentData = studentData;newNode->next = NULL;}return newNode;
}
//插入节点
void insertNodeByHead(struct student data)
{struct Node* newNode = createNode(data);//表头法插入,每次插入都将数据插入到头节点的下一个,先判断头节点是否为空,为空则新节点就是头节点,不为空,则插入在头节点的下一个位置if(studentList == NULL){studentList = newNode;}else//不改变头节点{newNode->next = studentList->next;studentList->next = newNode;}}//指定位置删除节点(知道这个节点的前驱和后续,然后进行删除)
void deleteAppointNode( char* studentId)
{//将链表头部设为指定位置,先判断头节点是否为空,为空则链表没有数据,无法删除//如果头节点不为空,则设头结点为指定位置,如果头结点是所找的节点,则删除,如果不是,设头结点的下一个为指定节点,头结点为指定节点的前驱节点,一直向下查询//指定位置struct Node* posNode = studentList;//指定位置的前面struct Node* posFrontNode = NULL;//查找指定节点if(posNode == NULL){printf("数据为空无法删除!\n");return;}else{//姓名是字符串,不能直接比较, strcmp(), 相等返回值为0,相同返回值为负数或者正数if(strcmp(posNode->studentData.studentId, studentId) ==0){studentList = studentList->next;free(posNode);return;}else{posFrontNode = posNode;posNode = posNode->next;//posFrontNode = posNode; //!!while(strcmp(posNode->studentData.studentId, studentId)){//继续向下一个节点移动posFrontNode = posNode;posNode = posFrontNode->next;if(posNode == NULL) //找到了链表尾部,没有找到数据{printf("未找到指定位置,无法删除!");return;}}//查到到对应数据后,进行删除,将该节点架空,然后释放该节点的存储单元posFrontNode->next = posNode->next;free(posNode);return;}}
}
//查找功能
struct Node* searchInfoByData(char* studentId)
{struct Node* pMove;pMove = studentList;if(pMove == NULL) //头节点为空,链表为空{//printf("学生链表为空!\n");return pMove;}else{// 查找到或者查找到链表最后,则结束循环,返回查询结果,结果为空,有两种可能,一种是链表中没有数据,另一种是没有查询到while(pMove != NULL){if(strcmp(pMove->studentData.studentId, studentId)==0)//找见{//printf("已查找到!\n");return pMove;}else{pMove = pMove->next;}}//printf("未找到!\n");return pMove;}
}//打印链表
void printList()
{struct Node* pMove = studentList;//涉及到展示数据//表头if(pMove == NULL){printf("No student record! Please add.\n");return;}else{printf("\t-------------------------------------------------------------------------------------\n");
printf("\t|%-10s |%-7s |%-4s |%-4s |%-12s |%-12s |%-12s |%-5s|\n","学号","姓名","性别","年龄","班级","专业","电话","入学成绩");printf("\t-------------------------------------------------------------------------------------\n");
while(pMove){printf("\t|%-10s |%-7s |%-4s |%-4d |%-12s |%-12s |%-12s |%-8d|\n", STUDENT_DATA);printf("\t-------------------------------------------------------------------------------------\n");pMove = pMove->next;}}printf("\n");
}
(8)AddStudent.h
#ifndef ADDSTUDENT_H_INCLUDED
#define ADDSTUDENT_H_INCLUDED
void AddStudent();  //录入学生信息
#endif // ADDSTUDENT_H_INCLUDED
(9)AddStudent.c
#include <stdio.h>
#include <conio.h>   //getc函数使用的头文件
#include <windows.h> //Sleep函数使用的头文件
#include <string.h>//strcmp函数使用的头文
#include "AddStudent.h"
#include "system.h"
#include  "MyList.h"//录入学生信息
void AddStudent()
{struct student studentData;struct Node* isNull = NULL;  //接收查询的返回值int iFlagExist;  //保证不重复输入char cFlag;int ret;  //用来接收scanf的返回值,判断输入数据是否正确system("cls");printf("===================================【录入学生信息】===============================\n");printf("\n请选择是否输入学生信息(y/n):");cFlag = getchar();getchar();while(cFlag != 'n' && cFlag!='y'){printf("输入有误,请输入‘y’或者‘n’!");printf("\n请选择是否输入学生信息(y/n):");cFlag = getchar();getchar();}if (cFlag == 'n')return;//循环输入学生信息可输入一条也可多条输入while (cFlag == 'y'){printf("请输入学生学号:");do{iFlagExist = 0;gets(studentData.studentId);//对学生编号在链表中进行查询,对查询结果进行判断,如果存在则重新输入,不存在则继续isNull = searchInfoByData(studentData.studentId);if(isNull!= NULL) //可以查询到{printf("该学生已经存在请重新输入!\n");printf("请输入学生学号:");iFlagExist = 1;}} while (iFlagExist == 1);//添加学生信息printf("请输入学生姓名:");ret = scanf("%s",studentData.name);while(ret!=1){printf("输入学生姓名有误,请重新输入!\n");printf("请输入学生姓名:");ret = scanf("%s",studentData.name);}getchar();printf("请输入学生性别(男-M,女-F):"); //这里采用防御式编程,如果不是M,F或者没有输入该项则重新输入while (gets(studentData.sex) != NULL){if (strcmp(studentData.sex, "F")==0 || strcmp(studentData.sex, "M")==0)break;printf("错误,只能输入'F'或者'M',请重新输入\n");printf("请输入学生性别(男-M,女-F):");}printf("请输入学生年龄(15-25):");ret = scanf("%d", &studentData.age);while((ret != 1) || studentData.age<15 || studentData.age>25){printf("输入年龄错误,请重新输入学生年龄(15-25):");ret = scanf("%d", &studentData.age);}getchar();printf("请输入学生班级(eg: B电子191):");gets(studentData.className);printf("请输入学生专业:");gets(studentData.major);printf("请输入学生电话:");gets(studentData.tel);printf("请输入学生入学成绩(200-750):");ret = scanf("%d", &studentData.score);while((ret != 1) || studentData.score<200 || studentData.score>750){printf("输入成绩信息错误,请重新输入学生入学成绩(200-750):");ret = scanf("%d", &studentData.score);}getchar();insertNodeByHead(studentData);fflush(stdin);printf("继续输入信息吗(y/n):");cFlag = getchar();getchar();while(cFlag != 'n' && cFlag!='y'){printf("输入有误,请输入‘y’或者‘n’!");printf("\n请选择是否输入学生信息(y/n):");cFlag = getchar();getchar();}}printf("添加学生信息执行完毕!\n");
}
(10)ShowStudent.h
#ifndef SHOWSTUDENT_H_INCLUDED
#define SHOWSTUDENT_H_INCLUDED
void ShowStudent(); //查找学生信息
#endif // SHOWSTUDENT_H_INCLUDED
(11)ShowStudent.c
#include <stdio.h>
#include <conio.h>   //getc函数使用的头文件
#include <windows.h> //Sleep函数使用的头文件
#include <string.h>//strcmp函数使用的头文
#include "ShowStudent.h"
#include "system.h"
#include  "MyList.h"
//浏览学生信息
void ShowStudent()
{system("cls");printf("\n");printf("\t====================================【浏览学生信息】================================\n");printf("\n\n");printList();}
(12)SearchStudent.h
#ifndef SEARCHSTUDENT_H_INCLUDED
#define SEARCHSTUDENT_H_INCLUDED
void SearchStudent(); //查找学生信息
#endif // SEARCHSTUDENT_H_INCLUDED
(13)SearchStudent.c
#include <stdio.h>
#include <conio.h>   //getc函数使用的头文件
#include <windows.h> //Sleep函数使用的头文件
#include <string.h>//strcmp函数使用的头文
#include "SearchStudent.h"
#include "system.h"
#include  "MyList.h"//查找学生信息
void SearchStudent()
{//查询成功,则返回该学生信息,查询失败则输出提示信息,可重新输入,也可退出struct student studentData;struct Node* pMove = NULL; //用来接收查询返回的结果char cFlag;  //接收用户的选择system("cls");printf("\n");printf("\t==================================【查找学生信息】==============================\n");printf("\t是否进行学生查询(y/n):");cFlag = getchar();getchar(); //接收回车键while(cFlag != 'n' && cFlag!='y'){printf("输入有误,请输入‘y’或者‘n’!");printf("\n请选择是否查询学生信息(y/n):");cFlag = getchar();getchar();}if (cFlag == 'n')return;while(cFlag == 'y'){printf("\t请输入需要查找的学生的学号:");//这里通过学号进行查询,学号是唯一的,姓名有重名现象gets(studentData.studentId);pMove = searchInfoByData(studentData.studentId);if(pMove)  //pMove 为真时,表示查询到{printf("\t查询成功,以下为该学生信息:\n");printf("\t-------------------------------------------------------------------------------------\n");printf("\t|%-10s |%-7s |%-4s |%-4s |%-12s |%-12s |%-12s |%-5s|\n","学号","姓名","性别","年龄","班级","专业","电话","入学成绩");printf("\t-------------------------------------------------------------------------------------\n");printf("\t|%-10s |%-7s |%-4s |%-4d |%-12s |%-12s |%-12s |%-8d|\n", STUDENT_DATA);printf("\t-------------------------------------------------------------------------------------\n");}else //pMove 为空时,未查询到,这里为空有两种情况,一种为学生名单为空,一种是没有查询到{printf("\t查询失败,该学生不存在或学生列表为空!\n");printf("\t是否重新查询(y/n):");cFlag = getchar();getchar();while(cFlag != 'n' && cFlag!='y'){printf("输入有误,请输入‘y’或者‘n’!");printf("\n是否重新查询学生信息(y/n):");cFlag = getchar();getchar();}}}printf("\t学生信息查询结束!\n");
}(14)DeleteStudent.h
#ifndef DELETESTUDENT_H_INCLUDED
#define DELETESTUDENT_H_INCLUDED
void DeleteStudent(); //删除学生信息
#endif // DELETESTUDENT_H_INCLUDED
(15)DeleteStudent.c
#include <stdio.h>
#include <conio.h>   //getc函数使用的头文件
#include <windows.h> //Sleep函数使用的头文件
#include <string.h>//strcmp函数使用的头文
#include "DeleteStudent.h"
#include "system.h"
#include  "MyList.h"
//删除学生信息
void DeleteStudent()
{//先根据学号对该学生进行查找,查找到则删除,没有查找到则输出提示信息struct student studentData;struct Node* pMove = NULL; //用来接收查询返回的结果char cFlag;system("cls");printf("\n");printf("\t==================================【删除学生信息】==============================\n");printf("\t请输入需要删除的学生的学号:");gets(studentData.studentId);pMove = searchInfoByData(studentData.studentId);if(pMove)  //该学生存在,进行删除{//先对学生信息进行展示printf("\t-------------------------------------------------------------------------------------\n");printf("\t|%-10s |%-7s |%-4s |%-4s |%-12s |%-12s |%-12s |%-5s|\n","学号","姓名","性别","年龄","班级","专业","电话","入学成绩");printf("\t-------------------------------------------------------------------------------------\n");printf("\t|%-10s |%-7s |%-4s |%-4d |%-12s |%-12s |%-12s |%-8d|\n", STUDENT_DATA);printf("\t-------------------------------------------------------------------------------------\n");printf("\t已查找到该学生信息,是否删除?(y/n)");cFlag = getchar();getchar(); //吃掉缓冲区的空格while(cFlag != 'n' && cFlag!='y'){printf("输入有误,请输入‘y’或者‘n’!");printf("\n请选择是否输入学生信息(y/n):");cFlag = getchar();getchar();}if(cFlag == 'n')return;else if(cFlag == 'y'){deleteAppointNode(studentData.studentId);printf("\t已删除该学生信息!\n");printf("\t删除操作执行结束!\n");}}else //找到了链表的末尾,或者链表为空{printf("\t该学生不存在!无法执行删除操作\n");}
}
(16)ModifyStudent.h
#ifndef MODIFYSTUDENT_H_INCLUDED
#define MODIFYSTUDENT_H_INCLUDED
#include "system.h"
void ModifyStudent();//修改学生信息
void ShowModifyMenu();//展示修改选项菜单
void dealSelection(struct student studentData, int selection, struct Node *pMove); //处理用户选择的修改项
#endif // MODIFYSTUDENT_H_INCLUDED
(17)ModifyStudent.c
#include <stdio.h>
#include <conio.h>   //getc函数使用的头文件
#include <windows.h> //Sleep函数使用的头文件
#include <string.h>//strcmp函数使用的头文
#include "ModifyStudent.h"
#include "system.h"
#include "MyList.h"//修改学生信息
void ModifyStudent()
{struct student studentData;struct Node* pMove = NULL; //对学生信息查询结果进行保存int selection;  //保存选择信息char isContinue = 'n';  //是否继续进行修改system("cls");printf("\n");printf("\t==================================【修改学生信息】==============================\n");printf("\t请输入需要修改信息的学生的学号:");gets(studentData.studentId);pMove = searchInfoByData(studentData.studentId);if(pMove == NULL){printf("\t该学生信息不存在,无法进行信息修改\n");return;}else  //可修改多条学生信息,也可以只修改一条学生信息{printf("\t-------------------------------------------------------------------------------------\n");printf("\t|%-10s |%-7s |%-4s |%-4s |%-12s |%-12s |%-12s |%-5s|\n","学号","姓名","性别","年龄","班级","专业","电话","入学成绩");printf("\t-------------------------------------------------------------------------------------\n");printf("\t|%-10s |%-7s |%-4s |%-4d |%-12s |%-12s |%-12s |%-8d|\n", STUDENT_DATA);printf("\t-------------------------------------------------------------------------------------\n");printf("\t是否进行学生信息的修改?(y/n)");scanf("%c", &isContinue);getchar();while(isContinue != 'n' && isContinue !='y'){printf("\t输入有误,请输入‘y’或者‘n’!");printf("\t请选择是否修改学生信息(y/n):");isContinue = getchar();getchar();}if(isContinue == 'n')return;else{while(isContinue == 'y'){//system('cls');ShowModifyMenu();//printf("\t请选择修改项: ");scanf("%d", &selection);getchar();//对用户的操作选择进行处理dealSelection(studentData,selection,pMove);fflush(stdin);printf("\t是否继续修改学生信息(y/n)?");isContinue = getchar();getchar();while(isContinue != 'n' && isContinue!='y'){printf("\n输入有误,请输入‘y’或者‘n’!");printf("\n请选择是否继续修改学生信息(y/n):");isContinue = getchar();getchar();}}printf("\t学生信息修改完毕!\n");}}}//学生信息修改菜单
void ShowModifyMenu()
{printf("\n");//printf("\t|              1.学号              |\n");printf("\t|              1.姓名              |\n");printf("\t|              2.性别              |\n");printf("\t|              3.年龄              |\n");printf("\t|              4.班级              |\n");printf("\t|              5.专业              |\n");printf("\t|              6.电话              |\n");printf("\t|              7.入学成绩          |\n");printf("\n");printf("请输入所要修改的信息(键入相应的数字:1-7):");
}//处理用户选择的修改项
void dealSelection(struct student studentData, int selection, struct Node* pMove)
{int ret; //用来接收scanf的返回值switch (selection){case 1:printf("\t请输入输入学生姓名:");gets(studentData.name);strcpy(pMove->studentData.name, studentData.name);break;case 2:printf("\t请输入学生性别(男-M,女-F):");while (gets(studentData.sex) != NULL){if (strcmp(studentData.sex, "F") == 0 || strcmp(studentData.sex, "M") == 0)break;printf("\t错误,只能输入'F'或者'M',请重新输入\n");printf("\t请输入学生性别(男-M,女-F):");}strcpy(pMove->studentData.sex,studentData.sex);break;case 3:printf("\t请输入学生年龄(15-25):");ret = scanf("%d", &studentData.age);while((ret != 1) || studentData.age<15 || studentData.age>25){printf("\t输入年龄错误,请重新输入学生年龄(15-25):");ret = scanf("%d", &studentData.age);}pMove->studentData.age = studentData.age;break;case 4:printf("\t请输入学生班级(eg:B电子191):");gets(studentData.className);strcpy(pMove->studentData.className, studentData.className);break;case 5:printf("\t请输入学生专业:");gets(studentData.major);strcpy(pMove->studentData.major, studentData.major);break;case 6:printf("\t请输入学生电话:");gets(studentData.tel);strcpy(pMove->studentData.tel, studentData.tel);break;case 7:printf("\t请输入学生入学成绩(100-750):");ret = scanf("%d", &studentData.score);while((ret != 1) || studentData.score<200 || studentData.score>750){printf("\t输入成绩信息错误,请重新输入学生入学成绩(200-750):");ret = scanf("%d", &studentData.score);}pMove->studentData.score = studentData.score;break;default:printf("\t\t请输入正确的数字!");break;}
}
(18)ShowStudentRanking.h
#ifndef SHOWSTUDENTRANKING_H_INCLUDED
#define SHOWSTUDENTRANKING_H_INCLUDED
#include "system.h"
void ShowRanking(); //显示学生排名
void sortByScore(struct studentRanking * stuRanking, int length);
void Ranking(struct studentRanking * stuRanking, int length);
#endif // SHOWSTUDENTRANKING_H_INCLUDED
(19)ShowStudentRanking.c
#include <stdio.h>
#include <conio.h>   //getc函数使用的头文件
#include <windows.h> //Sleep函数使用的头文件
#include <string.h>//strcmp函数使用的头文
#include "ShowStudentRanking.h"
#include "system.h"void ShowRanking()
{//*对链表中学生的成绩进行排名,并显示排名结果,排名结果括学号姓名班级专业入学成绩排名//*排名是struct studentRanking 的一个结构体成员,在得出排名后,再进行展示//*1.对链表中所有学生的成员进行排序,排序结果保存在student.ranking中//重新定义一个结构体,保存排名信息并输出//定义一个结构体数组struct Node *pMove = NULL;struct studentRanking *stuRanking;int i, j;int length = 0; //用来保存链表的长度system("cls");printf("\n");printf("\t==================================【学生排名信息】==============================\n");if(studentList == NULL){printf("学生登记为空,无法进行成绩排名\n");return;}else //学生链表头指针不为空,代表学生链表中存有学生信息{pMove = studentList;  //pMove指向链表的头//通过遍历得到链表有多少个存储单元for(i=0; pMove != NULL; i++){pMove = pMove->next;}length = i;printf("现有学生总人数为%d\n", length);//动态数组stuRanking = (struct studentRanking *)malloc(length * sizeof(struct studentRanking));if(stuRanking == NULL)return;//将需要输出的学生信息复制到结构体数组当中pMove = studentList;for(j=0; j<length; j++){strcpy(stuRanking[j].studentId, pMove->studentData.studentId);strcpy(stuRanking[j].name , pMove->studentData.name);strcpy(stuRanking[j].className , pMove->studentData.className);stuRanking[j].score = pMove->studentData.score;pMove = pMove->next;}//复制完成后,根据成绩对学生进行排序sortByScore(stuRanking, length);//根据排序结果,为每名同学添加排名信息Ranking(stuRanking, length);//展示排名printf("排名结果如下:\n");printf("\t-------------------------------------------------------\n");printf("\t|%-10s |%-7s |%-12s |%-5s |%-5s|\n","学号","姓名","班级","入学成绩","全级排名");printf("\t-------------------------------------------------------\n");for(j=0; j<length; j++){printf("\t|%-10s |%-7s |%-12s |%-8d |%-8d|\n", STUDENT_RANKING);printf("\t-------------------------------------------------------\n");}}printf("输出排名信息完毕!\n");system("pause");
}//通过成绩对链表中的数据进行排序
void sortByScore(struct studentRanking *stuRanking, int length)
{//进行冒泡排序,从大到小排序int i, j;struct studentRanking temp;for(i=0; i<length-1; i++){for(j=0; j<(length-i-1); j++){if(stuRanking[j].score < stuRanking[j+1].score)//后一项比前一项大,则交换两个存储单元中的数据,一轮排序下来,最小项就位,在列表的最末尾{temp = *(stuRanking+j);*(stuRanking+j) = *(stuRanking+j+1);*(stuRanking+j+1) =temp;}}}
}
void Ranking(struct studentRanking * stuRanking, int length)
{int i;for(i=1; i<=length; i++){stuRanking[i-1].ranking = i;}
}
(20)AboutFiles.h
#ifndef ABOUTFILES_H_INCLUDED
#define ABOUTFILES_H_INCLUDED
//链表的读取--文件读操作
void readInfoFromFile(char* fileName);
//链表的存储--文件写操作
void writeInfoToFile(char* fileName);
#endif // ABOUTFILES_H_INCLUDED
(21)ShowStudentRanking.c
#include <stdio.h>
#include <conio.h>   //getc函数使用的头文件
#include <windows.h> //Sleep函数使用的头文件
#include <string.h>//strcmp函数使用的头文
#include "system.h"
#include "AboutFiles.h"
#include  "MyList.h"//链表的读取--文件读操作
void readInfoFromFile(char* fileName)
{//步骤:先将信息读到data里面,再将信息读到文件里面//1.打开文件FILE *fp;struct student data;fp = fopen(fileName, "r");if(fp == NULL){fclose(fp);return NULL;}//2.读文件//格式化读取文件,没有读到文件结束标志,则一直读下去,读到的数据插入到链表里面else{while(fscanf(fp, "%s\t%s\t%s\t%d\t%s\t%s\t%s\t%d\n", data.studentId,data.name,data.sex,&data.age,data.className,data.major,data.tel,&data.score) != EOF){//将文件中原来的数据插入到链表当中insertNodeByHead(data);}//3.关闭文件,fclose(fp);}}//链表的存储--文件写操作
void writeInfoToFile(char* fileName)
{//1.打开文件D:\CodeBlocks\codeblocks C project\StudentSystemDemo02\studentListFILE *fp;struct Node* pMove = studentList;fp = fopen(fileName, "w");if(fp == NULL){//w+具有创建的功能,建立一个新文件可读可写fp = fopen(fileName, "w+");//可以给文件写入一个表头信息}//2.写文件, 按格式写入操作while(pMove != NULL){fprintf(fp,"%s\t%s\t%s\t%d\t%s\t%s\t%s\t%d\n", STUDENT_DATA);pMove = pMove->next;}//3.关闭文件fclose(fp);
}

C语言程序设计--新生入学登记系统相关推荐

  1. java计算机毕业设计临大新生入学指导系统源代码+数据库+系统+lw文档

    java计算机毕业设计临大新生入学指导系统源代码+数据库+系统+lw文档 java计算机毕业设计临大新生入学指导系统源代码+数据库+系统+lw文档 本源码技术栈: 项目架构:B/S架构 开发语言:Ja ...

  2. c语言开发题库管理系统,c语言程序设计_题库管理系统.doc

    c语言程序设计_题库管理系统 程序设计基础课程设计报告 班 级: 计算机科学与技术1103班 姓 名: 杨广宇 指导教师: 胡宏涛 完成日期: 2012年9月6日 (题目) 1. 设计题目与要求 (简 ...

  3. java毕业设计C语言程序设计》在线自学习系统Mybatis+系统+数据库+调试部署

    java毕业设计C语言程序设计>在线自学习系统Mybatis+系统+数据库+调试部署 java毕业设计C语言程序设计>在线自学习系统Mybatis+系统+数据库+调试部署 本源码技术栈: ...

  4. c语言程序设计飞机,C语言程序设计――飞机订票系统

    <C语言程序设计――飞机订票系统>由会员分享,可在线阅读,更多相关<C语言程序设计――飞机订票系统(7页珍藏版)>请在人人文库网上搜索. 1.C语言程序设计飞机订票系统代码如下 ...

  5. 基于PHP+HTML+MySQL的《C语言程序设计》在线考试系统

    资源下载地址:https://download.csdn.net/download/sheziqiong/85723936 资源下载地址:https://download.csdn.net/downl ...

  6. 机票退订c语言程序,c语言程序设计告飞机票预订系统.doc

    c语言程序设计告飞机票预订系统 目录 目录i 1课程设计的目的1 2需求分析1 2.1设计一个飞机订票系统,完成以下功能1 2.2该系统中用到的数据结构1 3概要设计2 3.1总体功能模块2 3.1. ...

  7. 基于javaweb新生入学报到系统

    使用该系统能方便的录入校园新闻.学生.班级等信息,并能实现管理员对新生报到的管理,主要角色分为学生,财务处,管理员.实现了宿舍楼管理,学籍建立,辅导员班级管理,宿舍安排,报到流程等模块,作为一款毕业设 ...

  8. 基于java web新生入学报到系统

    使用该系统能方便的录入校园新闻.学生.班级等信息,并能实现管理员对新生报到的管理,主要角色分为学生,财务处,管理员.实现了宿舍楼管理,学籍建立,辅导员班级管理,宿舍安排,报到流程等模块,作为一款毕业设 ...

  9. 有n个学生选修了c语言程序设计这门课程,C语言程序设计报告学生选修课系统(18页)-原创力文档...

    C 语 言 程 序 设 计 学校: 学院: 班级序号: 学号: :姓名 指导老师: C语言程序设计报告 一.C语言课程设计的目的: 高级语言课程设计是学习完<高级语言程序设计>课程后进行的 ...

  10. c语言运动会成绩统计报告,C语言程序设计运动会成绩统计系统1研究报告.doc

    PAGE 课 程 设 计 报 告 课程名称 <C语言程序设计> 课题名称 运动员分数统计系统 专 业 班 级 学 号 姓 名 指导教师 王颖 2015 年 1月9日 湖南工程学院课 程 设 ...

最新文章

  1. spring源码分析之cache注解
  2. 解析html文档的java库及范例
  3. Windows系统进程全解剖
  4. Linux 查看数据库MySQL安装文件和安装目录的命令
  5. linux下进程调度模拟程序,linux认证辅导:linux进程调度模拟怎么做?
  6. TensorFlow第三步 :单层网络-Mnist手写数字识别
  7. 【华为云技术分享】Batch Normalization (BN) 介绍
  8. 计算机管理是什么控件,Win7旗舰版系统WMI控件的功能作用是什么?
  9. android seekbar 源码,Android SeekBar调节音量
  10. .so动态链接库文件
  11. SharePoint 2010 获取列表全部定义方法
  12. 电商支付-使用Restful api接口集成Paypal支付方式(一)
  13. GAN生成图像质量的两个评价指标——IS与FID
  14. 如何快速通过信息系统管理工程师考试
  15. matplotlib 设置标注方向_原来Matplotlib绘图也可以这么漂亮,这次真的是学习到了...
  16. python镜像安装是什么意思_通过PyPI镜像安装Python包
  17. Python pta题目
  18. python workflow_如何用 Python 写 Alfred Workflow
  19. 【云计算课程】Lecture 1 云计算概述
  20. centos aarch64(arm64) iso 下载地址

热门文章

  1. 常用值得收藏的网站/软件 持续更新中
  2. zebradesigner2教程_zebradesigner pro 2中文版-斑马条码打印机软件下载 附带安装教程 - 安下载...
  3. 避坑宝典|win11升级最新预览体验版bug梳理
  4. 智慧城市——智慧社区解决方案
  5. 在黑客攻击之前软件安全检测是重点,软件安全检测机构怎么找?
  6. 软件安全测试是为了什么,一航软件测评有这些见解
  7. jmp连mysql_JMP官方教学视频列表
  8. 微信公众号推送模板信息
  9. 下载并安装JDK7 教程
  10. cmd imp导入dmp文件_oracle导入dmp文件的2种方法