C语言课程设计学生成绩管理系统.docx

上传人:b****5 文档编号:4599765 上传时间:2022-12-07 格式:DOCX 页数:22 大小:19.87KB
下载 相关 举报
C语言课程设计学生成绩管理系统.docx_第1页
第1页 / 共22页
C语言课程设计学生成绩管理系统.docx_第2页
第2页 / 共22页
C语言课程设计学生成绩管理系统.docx_第3页
第3页 / 共22页
C语言课程设计学生成绩管理系统.docx_第4页
第4页 / 共22页
C语言课程设计学生成绩管理系统.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

C语言课程设计学生成绩管理系统.docx

《C语言课程设计学生成绩管理系统.docx》由会员分享,可在线阅读,更多相关《C语言课程设计学生成绩管理系统.docx(22页珍藏版)》请在冰豆网上搜索。

C语言课程设计学生成绩管理系统.docx

C语言课程设计学生成绩管理系统

封面

作者:

PanHongliang

仅供个人学习

#include"stdio.h"

#include"string.h"

#include"stdlib.h"

#include"conio.h"

#include"string.h"

#include"fcntl.h"

typedefstructstudent

{

intnum。

chargrade[10]。

charclassroom[10]。

charname[10]。

floatscore_math。

floatscore_chinese。

floatscore_english。

floataverage。

floatsum。

}STU。

typedefstructNode

{

STUdata。

structNode*next。

}*linklist。

voidmenu()。

char*loginpassword(charpassword[],intn)。

//登录验证密码函数声明//

linklistcreatestulist(linklisthead)。

//创建学生链表即学生信息录入函数声明//

voidprintstulist(linklisthead)。

//学生信息输出函数声明//

voidsearchstu_namelist(linklisthead)。

//学生信息查询函数声明(按姓名)//

voidsearchstu_numlist(linklisthead)。

//学生信息查询函数声明(按学号)

linklistmodifystulist(linklisthead)。

//学生信息修改函数声明//

linklistdelatestulist(linklisthead)。

//学生信息删除函数声明//

voidsavestulist(linklisthead)。

//学生信息保存到文件函数声明//

linklistloadstulist()。

//从文件中读取学生信息函数声明//

voidsortstulist(linklisthead)。

//成绩排名函数(按年级)声明//

voidsort(STUstu[],intflag)。

//学生分班函数声明//

voidsortstuclass(linklisthead)。

//成绩排名函数(按班级)声明//

//*************************************//

voidmain()

{

charadmin[]="zhangqiong"。

charpassword[]="123456"。

charperson[20]。

charpassword1[10]。

inti。

intj=0。

printf("********************************************************************************\n")。

printf("\t\t**********欢迎来到学生成绩管理系统**********\n\n")。

printf("********************************************************************************\n\n")。

printf("\t\t\t\t用户登录\n\n\n\n")。

for(i=0。

i<3。

i++)

{

printf("用户名:

")。

gets(person)。

fflush(stdin)。

printf("\n\n\n")。

loginpassword(password1,10)。

printf("\n\n\n")。

if(strcmp(admin,person)==0&&strcmp(password,password1)==0)

{

printf("\t\t\t\t成功登录,亲!

\n")。

printf("\n\n")。

printf("按任意键继续!

")。

getch()。

menu()。

break。

}

else

printf("\t用户名或者密码输入错误\n")。

}

if(i==3)

printf("\t对不起,您今天输入次数太多,已被强制退出!

\n")。

}

//**********************************************************//

//**********************************************************//

char*loginpassword(charpassword[],intn)//登录密码函数,隐藏密码可见//

{

inti=0。

intm=0。

charch。

printf("用户密码:

")。

while((ch=getch())!

='\r'&&m

{

password[i++]=ch。

printf("*")。

m++。

}

password[i]='\0'。

returnpassword。

}

//***************************************************//

voidmenu()//主界面函数//

{

system("cls")。

linklistL。

L=(linklist)malloc(sizeof(Node))。

L->next=NULL。

intch。

do

{

printf("\t----------******------------******-----------******----------\n\n")。

printf("\t\t\t**********学生成绩管理系统***********\n\n")。

printf("\t----------******------------******-----------******----------\n\n\n\n\n")。

printf("\t1.录入学生成绩信息\n\t2.输出学生成绩信息\n\t3.按学号查找学生信息\n\t4.按姓名查找学生信息\n\t5.修改学生信息\n\t6.删除学生信息\n\t7.保存学生信息到文件\n\t8.从文件中读取学生信息\n\t9.年级总成绩排序\n\t10.班级总成绩排序\n\t11.退出\n")。

printf("\n\n")。

printf("请输入您要查询的工程:

\n")。

scanf("%d",&ch)。

switch(ch)

{

case1:

system("cls")。

createstulist(L)。

break。

case2:

system("cls")。

printstulist(L)。

break。

case3:

system("cls")。

searchstu_numlist(L)。

break。

case4:

system("cls")。

searchstu_namelist(L)。

break。

case5:

system("cls")。

modifystulist(L)。

break。

case6:

system("cls")。

delatestulist(L)。

break。

case7:

system("cls")。

savestulist(L)。

break。

case8:

system("cls")。

L=loadstulist()。

break。

case9:

system("cls")。

sortstulist(L)。

break。

case10:

system("cls")。

sortstuclass(L)。

break。

case11:

system("cls")。

exit(0)。

}

}while

(1)。

}

//************************************//

linklistcreatestulist(linklistL)//录入信息函数//

{

linklistp,q。

charch。

q=L。

printf("*******请输入学生信息*******\n\n\n")。

do

{

p=(linklist)malloc(sizeof(Node))。

if(!

p)

{

printf("没有多余内存空间\n")。

returnL。

}

printf("请输入学号:

\n")。

scanf("%d",&p->data.num)。

printf("请输入姓名:

\n")。

scanf("%s",&p->data.name)。

printf("请输入年级:

\n")。

scanf("%s",&p->data.grade)。

printf("请输入班级:

\n")。

scanf("%s",&p->data.classroom)。

printf("请输入数学成绩:

\n")。

scanf("%f",&p->data.score_math)。

while(p->data.score_math>100)

{

printf("成绩超过100了,你是猪吗?

\n")。

printf("给老子重新输入:

\n")。

scanf("%f",&p->data.score_math)。

}

printf("请输入语文成绩:

\n")。

scanf("%f",&p->data.score_chinese)。

while(p->data.score_chinese>100)

{

printf("成绩超过100了,你是猪吗?

\n")。

printf("给老子重新输入:

\n")。

scanf("%f",&p->data.score_chinese)。

}

printf("请输入英语成绩:

\n")。

scanf("%f",&p->data.score_english)。

while(p->data.score_english>100)

{

printf("成绩超过100了,你是猪吗?

\n")。

printf("给老子重新输入:

\n")。

scanf("%f",&p->data.score_english)。

}

p->data.sum=p->data.score_math+p->data.score_chinese+p->data.score_english。

p->data.average=p->data.sum/3。

q->next=p。

q=p。

q->next=NULL。

printf("是否要输入下一个学生的信息(Y/N)!

")。

fflush(stdin)。

ch=getchar()。

system("cls")。

}while(ch=='Y'||ch=='y')。

return(L)。

}

//*****************************************//

voidprintstulist(linklistL)//输出信息函数//

{

linklistp。

p=L->next。

if(p==NULL)

{

printf("请先录入学生信息,亲!

\n")。

}

else

while(p!

=NULL)

{

printf("学号姓名年级班级数学成绩语文成绩英语成绩总分平均成绩\n")。

printf("%6d%3s%2s%2s%4.1f%4.1f%4.1f%4.1f%4.1f\n",p->data.num,p->data.name,p->data.grade,p->data.classroom,p->data.score_math,p->data.score_chinese,p->data.score_english,p->data.sum,p->data.average)。

p=p->next。

}

printf("按任意键继续\n")。

getch()。

system("cls")。

}

//*******************************************************//

voidsearchstu_namelist(linklistL)//按姓名查询函数//

{

linklistp。

charstr[10]。

printf("请输入要查询的学生姓名:

\n")。

scanf("%s",str)。

p=L->next。

if(p==NULL)

{

printf("请先录入学生信息\n")。

}

while(p!

=NULL)

{

if(strcmp(p->data.name,str)==0)

{

printf("学号姓名年级班级数学成绩语文成绩英语成绩总分平均成绩\n")。

printf("%6d%3s%2s%2s%4.1f%4.1f%4.1f%4.1f%4.1f\n",p->data.num,p->data.name,p->data.grade,p->data.classroom,p->data.score_math,p->data.score_chinese,p->data.score_english,p->data.sum,p->data.average)。

}

p=p->next。

}

printf("按任意键继续\n")。

getch()。

system("cls")。

}

//****************************************//

voidsearchstu_numlist(linklistL)//按学号查询函数//

{

linklistp。

intnumber。

printf("请输入要查询的学生学号:

\n")。

scanf("%d",&number)。

p=L->next。

if(p==NULL)

{

printf("请先录入学生信息\n")。

}

while(p!

=NULL)

{

if(p->data.num==number)

{

printf("学号姓名年级班级数学成绩语文成绩英语成绩总分平均成绩\n")。

printf("%6d%3s%2s%2s%4.1f%4.1f%4.1f%4.1f%4.1f\n",p->data.num,p->data.name,p->data.grade,p->data.classroom,p->data.score_math,p->data.score_chinese,p->data.score_english,p->data.sum,p->data.average)。

}

p=p->next。

}

printf("按任意键继续\n")。

getch()。

system("cls")。

}

//*****************************************************//

linklistdelatestulist(linklistL)//删除信息函数//

{

linklistp,q。

intnumber。

charch。

printf("请输入要删除的学生学号:

\n")。

scanf("%d",&number)。

p=L->next。

if(p==NULL)

{

printf("请先录入学生信息\n")。

returnNULL。

}

while(p!

=NULL)

{

if(p->data.num==number)

{

printf("学号姓名年级班级数学成绩语文成绩英语成绩总分平均成绩\n")。

printf("%6d%3s%2s%2s%4.1f%4.1f%4.1f%4.1f%4.1f\n",p->data.num,p->data.name,p->data.grade,p->data.classroom,p->data.score_math,p->data.score_chinese,p->data.score_english,p->data.sum,p->data.average)。

printf("确定要删除该学生的信息吗?

(Y/N)\n")。

fflush(stdin)。

ch=getchar()。

if(ch=='Y'||ch=='y')

{

q=L。

while(q->next!

=p)

q=q->next。

if(q->next=p)

{

if(p->next==NULL)

q->next=NULL。

else

q->next=p->next。

free(p)。

printf("已删除该学生的相关信息!

\n")。

return(L)。

}

}

else

returnNULL。

}

else

p=p->next。

}

printf("按任意键继续\n")。

getch()。

system("cls")。

}

//***************************************//

voidsavestulist(linklistL)//存盘函数//

{

FILE*fp。

linklistp。

charoutfile[20]。

printf("请输入你要保存信息的文件名:

(例如:

D:

\\学生管理系统\\student.text)\n")。

scanf("%s",outfile)。

if((fp=fopen(outfile,"w"))==NULL)

{

printf("文件打开失败\n")。

exit

(1)。

}

p=L。

while(p!

=NULL)

{

fwrite(p,sizeof(Node),1,fp)。

p=p->next。

}

fclose(fp)。

printf("信息保存成功!

\n")。

printf("请按任意键继续\n")。

getch()。

system("cls")。

}

//*******************************************//

linklistloadstulist()//读盘函数//

{

linklistq,p,L。

L=NULL。

FILE*fp。

charinfile[20]。

printf("请输入要打开的文件名:

\n")。

scanf("%s",infile)。

if((fp=fopen(infile,"rb"))==NULL)

{

printf("文件打开失败!

\n")。

exit

(1)。

}

printf("正在打开文件....\n")。

p=(linklist)malloc(sizeof(Node))。

if(!

p)

{

printf("无法申请到内存空间")。

returnL。

}

L=p。

while(!

feof(fp))

{

if(fread(p,sizeof(Node),1,fp)!

=1)

{

printf("读取信息失败!

\n")。

break。

}

p->next=(linklist)malloc(sizeof(Node))。

if(!

p->next)

{

printf("无法申请到内存空间")。

returnL。

}

q=p。

p=p->next。

}

q->next=NULL。

fclose(fp)。

printf("读取成功!

\n")。

returnL。

}

//*************************************************//

voidsortstulist(linklistL)//年级排序函数//

{

STUstu[1000]。

inti=0。

intflag=0。

linklistp。

p=L->next。

if(p==NULL)

{

printf("请先录入学生信息,亲!

\n")。

}

while(p!

=NULL&&i<1000)

{

stu[i]=p->data。

i++。

p=p->next。

flag++。

}

printf("正在排序.....\n")。

sort(stu,flag)。

}

//******************************************************//

voidsort(STUstu[],intflag)

{

inti,j。

STUtemp。

for(i=1。

i

i++)

for(j=0。

j

j++)

{

if(stu[j].sum>stu[j+1].sum)

{

temp=stu[j]。

stu[j]=stu[j+1]。

stu[j+1]=temp。

}

}

printf("学号姓名年级班级数学成绩语文成绩英语成绩总分平均成绩\n")。

for(i=flag-1。

i>=0。

i--)

printf("%6d%3s%2s%2s%4.1f%4.1f%4.1f%4.1f%4.1f\n",stu[i].num,stu[i].name,stu[i].grade,stu[i].classroom,stu[i].score_math,stu[i].score_chinese,stu[i].score_english,stu[i].sum,stu[i].average)。

printf("按任意键继续!

\n")。

getch()。

system("cls")。

}

//*****************************************************//

voidsortstuclass(linklistL)//班级排序函数//

{

STUstu[1000]。

inti=0。

STUc1[100],c2[100],c3[100],c4[100],c5[100],c6[100],c7[100],c8[100]。

intflag=0,flag1=0,flag2=0,flag3=0,flag4=0,flag5=0,flag6=0,flag7=0,f

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 高中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1