c语言程序设计课程学籍管理系统源代码.docx
《c语言程序设计课程学籍管理系统源代码.docx》由会员分享,可在线阅读,更多相关《c语言程序设计课程学籍管理系统源代码.docx(19页珍藏版)》请在冰豆网上搜索。
![c语言程序设计课程学籍管理系统源代码.docx](https://file1.bdocx.com/fileroot1/2022-10/18/5c6760c9-7495-4a6e-bf40-4f3953d95632/5c6760c9-7495-4a6e-bf40-4f3953d956321.gif)
c语言程序设计课程学籍管理系统源代码
附表1.程序源码
#include#include#include#include#defineN100structstudent{
charnum[13];charname[18];floatmath;floatenglish;floatcprogram;floatcircuit;floatlaw;
floatpingjun;floatscore[5];
};
voidmainprint();voidscoreprint();voidstudentprint();voidscoreInput();voidscoreStat();voidstudentStatus();voidbukao();voidtuixue();voidxinmingdan();voidsortAnhao();voidjisuanPingjun();voidtongjiFenshu();voidfenxi();
voidmynew();/*创新功能*/
voidoutstudent();
voidoutdanke();
voidteshutuixue();
voidmain()
{
charchoose='\0',yes_no='\0';
do{system("color4f");system("cls");mainprint();
printf("");choose=getche();
switch(choose)
{case'1':
scoreInput();break;/*成绩录入*/case'2':
scoreStat();break;
case'3':
studentStatus();break;case'4':
mynew();break;
case'0':
break;
default:
printf("\n%c是非法选项!
\n");break;
}
if(choose=='0')break;
printf("\n即将进入主菜单,要继续选择吗(Y/N)?
\n");do
{yes_no=getche();
}while(yes_no!
='Y'&&yes_no!
='y'&&yes_no!
='N'&&yes_no!
='n');}while(yes_no=='y'||yes_no=='Y');
}
voidmainprint()
{printf("
|******************************************|\n");
printf("
|欢迎使用学籍管理系统
|\n");
printf("
|******************************************|\n");
printf("
|请输入选项编号(0~4)
|\n");
printf("
||\n");
printf("
|1--录入成绩
|\n");
printf("
|2--统计成绩
|\n");
printf("
|3--处理学籍
|\n");
printf("
|4--创新功能
|\n");
printf("
|0--退出
|\n");
|\n");
printf("
}
voidscoreInput()
{inti=0;charyes_no='\0';
structstudentex1[N]={0};
FILE*fp=NULL;
system("color5f");
system("cls");
学生基本信息.txt","w");
if(fp==NULL)
{printf("\n打开文件失败!
\n");return;}
printf("\n欢迎进入成绩录入系统\n");
printf("\n请输入第%d个记录:
\n",i+1);
printf("\n输入学生学号:
(用#结束程序)");
scanf("%s",ex1[i].num);
printf("\n输入学生姓名:
(用#结束程序)");
scanf("%s",ex1[i].name);
printf("\n请依次输入学生的数学、英语、c编程、电路设计和法律基础的成绩:
\n");scanf("%f%f%f%f%f",&ex1[i].math,&ex1[i].english,&ex1[i].cprogram,&ex1[i].circuit,&ex1[i].law);while(ex1[i].num[0]!
='#'&&ex1[i].name[0]!
='#')
{fprintf(fp,"%3d%15s%16s%7.1f%7.1f%7.1f%7.1f%7.1f\n",i,ex1[i].num,ex1[i].name,ex1[i].math,ex1[i].english,ex1[i].cprogram,ex1[i].circuit,ex1[i].law);
i++;
printf("\n请输入第%d个记录:
\n",i+1);
printf("\n输入学生学号:
(用#结束程序)");
scanf("%s",ex1[i].num);
printf("\n输入学生姓名:
(用#结束程序)");scanf("%s",ex1[i].name);
printf("\n请依次输入学生的数学、英语、c编程、电路设计和法律基础的成绩:
\n");scanf("%f%f%f%f%f",&ex1[i].math,&ex1[i].english,&ex1[i].cprogram,&ex1[i].circuit,&ex1[i].law);
}
fclose(fp);
}
voidscoreStat()
{charchoose='\0',yes_no='\0';
system("color9f");
do
{
system("cls");
printf("\n欢迎选择成绩统计系统\n");
/*显示菜单*/
|");
printf("\n
printf("\n|请输入选项编号(0~4)|");
printf("\n
||");
printf("\n
|1--按学号排序
|");
printf("\n
|2--按平均分数排序
|");
printf("\n
|3--统计分数段
|");
printf("\n
|4--返回
|");
printf("\n
|0--退出系统
|");
printf("\n
||\n");
choose=getch();
switch(choose)
{case'1':
sortAnhao();break;
case'2':
jisuanPingjun();break;
case'3':
tongjiFenshu();break;
case'4':
main();break;
case'0':
break;
default:
printf("\n%c是非法选项!
\n");break;
}
if(choose=='0')break;
printf("\n要继续选择吗(Y/N)?
\n");
do
{yes_no=getche();}while(yes_no!
='Y'&&yes_no!
='y'&&yes_no!
='N'&&yes_no!
='n');
}while(yes_no=='y'||yes_no=='Y');
}
voidsortAnhao()
{inti=0,j=0,n=0;
structstudentex2[N]={0},temp={0};
FILE*fp=NULL;system("color9f");
学生基本信息.txt","r");
if(fp==NULL)
{printf("\n打开文件失败!
\n");return;}printf("\n欢迎进入按学号排序系统\n");
while(feof(fp)==0)
{fscanf(fp,"%3d%15s%16s%f%f%f%f%f\n",&i,&ex2[i].num,ex2[i].name,&ex2[i].math,&ex2[i].english,&ex2[i].cprogram,&ex2[i].circuit,&ex2[i].law);
i++;n++;}
fclose(fp);
for(i=0;ifor(j=i+1;jif(strcmp(ex2[i].num,ex2[j].num)>0)
{temp=ex2[i];
ex2[i]=ex2[j];
ex2[j]=temp;
}按学号排序.txt","w");
if(fp==NULL)
{printf("\n打开文件失败!
\n");return;}
fprintf(fp,"序号学号姓名高数英语编程电路法律\n");
for(i=0;ifprintf(fp,"%3d%15s%16s%7.1f%7.1f%7.1f%7.1f%7.1f\n",i,ex2[i].num,ex2[i].name,ex2[i].math,ex2[i].engl
按学号排序.txt\n");
ish,ex2[i].cprogram,ex2[i].circuit,ex2[i].law);
printf("\n文件已保存至fclose(fp);
}
voidjisuanPingjun(){inti=0,j=0,n=0;
charc='\0';
structstudentex2[N]={0},temp={0};
FILE*fp=NULL;system("color9f");
学生基本信息.txt","r");
\n");return;}欢迎使用按学号排序系统\n");
while(feof(fp)==0)
{fscanf(fp,"%3d%15s%16s%f%f%f%f%f\n",&i,ex2[i].num,ex2[i].name,&ex2[i].math,&ex2[i].english,&ex2[i].cprogram,&ex2[i].circuit,&ex2[i].law);
i++;n++;}
fclose(fp);
for(i=0;iex2[i].pingjun=(ex2[i].math+ex2[i].english+ex2[i].cprogram+ex2[i].circuit+ex2[i].law)/5;for(i=0;ifor(j=i+1;jif(ex2[i].pingjun{temp=ex2[i];
ex2[i]=ex2[j];
ex2[j]=temp;
}
按平均成绩排序.txt","w");
if(fp==NULL)
{printf("\n打开文件失败!
\n");return;}
fprintf(fp,"序号学号姓名高数英语编程电路法律平均\n");
for(i=0;ifprintf(fp,"%3d%15s%16s%7.1