所有分类
  • 所有分类
  • 实时新闻

课程设计:学生成绩管理系统!400行C语言源码让你交上作业

近期很多小伙伴私信我说,临近期末考试,需要一份课程设计学生成绩管理系统来交作业!

今天,它来了!400行源码的学生管理系统,只需要你正确移植到你的电脑上,即可使用,这还不点个关注+收藏嘛!

课程设计:学生成绩管理系统!400行C语言源码让你交上作业

源码分享:

define_CRT_SECURE_NO_WARNINGSincludeincludeincludecharfilename[20] = {0};typedefstructStudent{intnum;charname[10];floatchinese;floatmath;floatenglish;floattotal;structStudent*next;}STU;intMainInterface(){intkey;

system("cls");printf("\n\n");printf("\t\t\t=============================================\n");printf("\t\t\t|          欢迎来到学生成绩管理系统        |\n");printf("\t\t\t|===========================================|\n");printf("\t\t\t|                                          |\n");printf("\t\t\t|                1.录入学员                |\n");printf("\t\t\t|                2.查找学员                |\n");printf("\t\t\t|                3.删除学员                |\n");printf("\t\t\t|                4.修改成绩                |\n");printf("\t\t\t|                5.打开文件                |\n");printf("\t\t\t|                0.退出系统                |\n");printf("\t\t\t|                                          |\n");printf("\t\t\t=============================================\n");printf("\t\t\t请选择:");scanf("%d", &key);returnkey;

}STU*CreateList(){

STU* p = (STU*)malloc(sizeof(STU));if(p !=NULL)

p->next =NULL;returnp;

}intNumIsExist(STU* plist,intnum){

plist = plist->next;while(plist !=NULL)

{if(plist->num == num)return1;

plist = plist->next;

}return0;

}voidInsertStu(STU* plist){

system("cls");printf("\n\n");printf("\t\t\t=============================================\n");printf("\t\t\t|              正在录入学员信息            |\n");printf("\t\t\t=============================================\n");

STU* p = plist;intcount =0;printf("\t\t\t请问需要添加多少学员:");scanf("%d",&count);if(count <=0)return;for(inti =0; i < count; i++) {

STU* pnew = (STU*)malloc(sizeof(STU));if(pnew ==NULL)return;printf("\t\t\t请输入学生学号:");scanf("%d", &pnew->num);while(1)

{if(NumIsExist(plist, pnew->num))

{printf("\t\t\t学号重复,请重新输入学号:");scanf("%d", &pnew->num);

}elsebreak;

}printf("\t\t\t请输入学生姓名:");scanf("%s", pnew->name);printf("\t\t\t请输入语文成绩:");scanf("%f", &pnew->chinese);printf("\t\t\t请输入数学成绩:");scanf("%f", &pnew->math);printf("\t\t\t请输入英语成绩:");scanf("%f", &pnew->english);

pnew->total = pnew->chinese + pnew->math + pnew->english;

pnew->next =NULL;//头插法? 尾插法? 任意位置插入?p = plist;while(p->next !=NULL)

{if(pnew->num < p->next->num)

{

pnew->next = p->next;

p->next = pnew;break;

}

p=p->next;

}

p->next = pnew;

}

}voidSerchByNum(STU* plist){intnum =0;

system("cls");printf("\n\n");printf("\t\t\t=============================================\n");printf("\t\t\t|              正在查找学员信息            |\n");printf("\t\t\t=============================================\n");printf("\t\t\t请输入学员学号:");scanf("%d", &num);while(plist !=NULL)

{if(plist->num == num)

{printf("\t\t\t学号\t姓名\t语文\t数学\t英语\t总分\n");printf("\t\t\t%d\t%s\t%.1f\t%.1f\t%.1f\t%.1f\n",

plist->num, plist->name, plist->chinese,

plist->math, plist->english,plist->total);printf("\t\t\t");

system("pause");return;

}

plist = plist->next;

}printf("\t\t\t没有找到该学生!!\n");printf("\t\t\t");

system("pause");

}voidSerchByName(STU* plist){charname[10] = {0};

system("cls");printf("\n\n");printf("\t\t\t=============================================\n");printf("\t\t\t|              正在查找学员信息            |\n");printf("\t\t\t=============================================\n");printf("\t\t\t请输入学员姓名:");scanf("%s", &name);intn =1;while(plist !=NULL)

{if(strcmp(name, plist->name) ==0)

{if(n) {printf("\t\t\t学号\t姓名\t语文\t数学\t英语\t总分\n");

n =0;

}printf("\t\t\t%d\t%s\t%.1f\t%.1f\t%.1f\t%.1f\n",

plist->num, plist->name, plist->chinese,

plist->math, plist->english, plist->total);

}

plist = plist->next;

}if(n)printf("\t\t\t没有找到该学生!!\n");printf("\t\t\t");

system("pause");

}voidSerchAllStu(STU* plist){

plist = plist->next;

system("cls");printf("\n\n");printf("\t\t\t=============================================\n");printf("\t\t\t|              正在查找学员信息            |\n");printf("\t\t\t=============================================\n");if(plist ==NULL)

{printf("\t\t\t没有学员信息!\n");printf("\t\t\t");

system("pause");return;

}printf("\t\t\t学号\t姓名\t语文\t数学\t英语\t总分\n");while(plist !=NULL)

{printf("\t\t\t%d\t%s\t%.1f\t%.1f\t%.1f\t%.1f\n",

plist->num, plist->name, plist->chinese,

plist->math, plist->english, plist->total);

plist = plist->next;

}printf("\t\t\t");

system("pause");

}voidSerchMain(STU* plist){intkey;do{

system("cls");printf("\n\n");printf("\t\t\t=============================================\n");printf("\t\t\t|              正在查找学员信息            |\n");printf("\t\t\t|===========================================|\n");printf("\t\t\t|                                          |\n");printf("\t\t\t|                1.按学号查找              |\n");printf("\t\t\t|                2.按姓名查找              |\n");printf("\t\t\t|                3.查看所有项              |\n");printf("\t\t\t|                0.返回主菜单              |\n");printf("\t\t\t|                                          |\n");printf("\t\t\t=============================================\n");printf("\t\t\t请选择:");scanf("%d", &key);switch(key) {case1:SerchByNum(plist);break;case2:SerchByName(plist);break;case3:SerchAllStu(plist);break;

}

}while(key !=0);

}voidDeleteStu(STU* plist){intnum =0;charkey =\0;

STU* pre = plist;

STU* p = plist->next;

system("cls");printf("\n\n");printf("\t\t\t=============================================\n");printf("\t\t\t|              正在准备删除信息            |\n");printf("\t\t\t=============================================\n");printf("\t\t\t请输入需要删除的学号:");scanf("%d", &num);while(p !=NULL)

{if(p -> num == num)

{printf("\t\t\t学号\t姓名\t语文\t数学\t英语\t总分\n");printf("\t\t\t%d\t%s\t%.1f\t%.1f\t%.1f\t%.1f\n",

p->num, p->name, p->chinese,

p->math, p->english, p->total);printf("\t\t\t是否删除? [Y/N] : ");

getchar();scanf("%c",&key);if(key ==N|| key ==n)return;elseif(key ==Y|| key ==y)

{

pre->next = p->next;free(p);

p =NULL;printf("\t\t\t删除成功!!\n");printf("\t\t\t");

system("pause");return;

}

}

pre = pre->next;

p = p->next;

}printf("\t\t\t没有找到该学生!!\n");printf("\t\t\t");

system("pause");

}voidModifyStu(STU* plist){intnum =0;

STU* p = plist->next;charkey =\0;

system("cls");printf("\n\n");printf("\t\t\t=============================================\n");printf("\t\t\t|              正在准备修改信息            |\n");printf("\t\t\t=============================================\n");printf("\t\t\t请输入需要修改的学号:");scanf("%d", &num);while(p !=NULL)

{if(num == p->num)

{printf("\t\t\t学号\t姓名\t语文\t数学\t英语\t总分\n");printf("\t\t\t%d\t%s\t%.1f\t%.1f\t%.1f\t%.1f\n",

p->num, p->name, p->chinese,

p->math, p->english, p->total);printf("\t\t\t是否修改? [Y/N] : ");

getchar();scanf("%c", &key);if(key ==N|| key ==n)return;elseif(key ==Y|| key ==y)

{printf("\n\t\t\t==============\n");printf("\t\t\t1.修改姓名\n\t\t\t2.修改语文\n\t\t\t3.修改数学\n\t\t\t4.修改英语\n\t\t\t0.返回\n");printf("\t\t\t==============\n");printf("\t\t\t请选择:");

getchar();scanf("%c", &key);if(key ==1) {printf("\t\t\t新的姓名:");scanf("%s", p->name);

}elseif(key ==2) {printf("\t\t\t新的语文成绩:");scanf("%f", &p->chinese);

}elseif(key ==3) {printf("\t\t\t新的数学成绩:");scanf("%f", &p->math);

}elseif(key ==4) {printf("\t\t\t新的英语成绩:");scanf("%f", &p->english);

}elseif(key ==0)return;printf("\t\t\t修改后的信息如下:\n");printf("\t\t\t学号\t姓名\t语文\t数学\t英语\t总分\n");printf("\t\t\t%d\t%s\t%.1f\t%.1f\t%.1f\t%.1f\n",

p->num, p->name, p->chinese,

p->math, p->english, p->total);printf("\t\t\t");

system("pause");return;

}

}

p = p->next;

}printf("\t\t\t没有找到该学员!!\n");printf("\t\t\t");

system("pause");

}STU*OpenStuFile(){charc;

STU* pstu =NULL;

STU* ptem =NULL;

FILE* fp =NULL;while(1){

system("cls");printf("\n\n");printf("\n\n");printf("\t\t\t=============================================\n");printf("\t\t\t|          欢迎来到学生成绩管理系统        |\n");printf("\t\t\t|                                          |\n");printf("\t\t\t|            【源码联系群中老师】          |\n");printf("\t\t\t|                                          |\n");printf("\t\t\t|            【源码联系群中老师】          |\n");printf("\t\t\t|                                          |\n");printf("\t\t\t|            【源码联系群中老师】          |\n");printf("\t\t\t|                                          |\n");printf("\t\t\t|              【学编程,来顿开】          |\n");printf("\t\t\t|                                          |\n");printf("\t\t\t=============================================\n");printf("\t\t\t请输入班级(如:3年2班):");scanf("%s", filename);

fp = fopen(filename,"rb+");if(fp !=NULL)break;//打开成功printf("\t\t\t文件不存在!是否创建该文件? [Y/N] : ");

getchar();scanf("%c", &c);if(c ==Y|| c ==y)

{

fp = fopen(filename,"wb+");if(fp !=NULL)break;elsecontinue;

}elsecontinue;

}

pstu = CreateList();while(1)

{

STU* pnew = (STU*)malloc(sizeof(STU));

pnew->next =NULL;if(fscanf(fp,"%d\t%s\t%f\t%f\t%f\t%f\n",

&pnew->num, pnew->name, &pnew->chinese,

&pnew->math, &pnew->english, &pnew->total) == EOF)

{free(pnew);

pnew =NULL;break;

}//头插法? 尾插法? 任意位置插入?ptem = pstu;while(ptem->next !=NULL)

{if(pnew->num < ptem->next->num)

{

pnew->next = ptem->next;

ptem->next = pnew;break;

}

ptem = ptem->next;

}

ptem->next = pnew;

}

fclose(fp);returnpstu;

}voidCloseStuFile(STU* plist){

FILE* fp =NULL;

plist = plist->next;//只写方式打开文件if((fp = fopen(filename,"wb+")) ==NULL)

{printf("打开文件失败!");

}else{//遍历链表输出到文件while(plist !=NULL)

{fprintf(fp,"%d\t%s\t%.1f\t%.1f\t%.1f\t%.1f\n",

plist->num, plist->name, plist->chinese,

plist->math, plist->english, plist->total);

plist = plist->next;

}

}

fclose(fp);

}intmain(){intkey =-1;

STU* pList =NULL;

pList = OpenStuFile();//初始化链表while(key !=0) {

key = MainInterface();switch(key) {case1: InsertStu(pList);break;case2: SerchMain(pList);break;case3: DeleteStu(pList);break;case4:ModifyStu(pList);break;case0:CloseStuFile(pList);break;

}

}return0;

}

好了,赶紧去完成你的课程设计吧!不要忘了留下你的关注和点赞哟~

另外,对现在我们的大多数朋友来说还是学编程技术最重要!栽一棵树最好的时间是十年前,其次是现在。对于准备学习编程的小伙伴,如果你想更好的提升你的编程核心能力(内功)不妨从现在开始!

编程学习书籍分享:

课程设计:学生成绩管理系统!400行C语言源码让你交上作业

编程学习视频分享:

课程设计:学生成绩管理系统!400行C语言源码让你交上作业

整理分享(多年学习的源码、项目实战视频、项目笔记,基础入门教程)

欢迎转行和学习编程的伙伴,利用更多的资料学习成长比自己琢磨更快哦!

点击下方【了解更多】获取更多学习资料帮助你学习成长哦~

原文链接:https://www.w1ym.com/82541/,转载请注明出处~~~
0

评论0

请先

站点公告

【温馨提示】 本站不建议您对本站支付任何费用或开通任何会员本站99%资源为免费资源只提供共享不提供技术支持,本站资源主要以学习开发为主,本站是为个人资源记录学习研究等情况而建立,如特殊原因下载,需在24小时删除相关资源。本站资源均来自互联网收集或网友分享,若有侵权,请联系站长删除,谢谢。立即查看
显示验证码
没有账号?注册  忘记密码?