c语言程序设计课程学籍管理系统源代码
附表 1.程序源码
#include
char num[13]; char name[18]; float math; float english; float cprogram; float circuit; float law;
float pingjun; float score[5];
};
void mainprint(); void scoreprint(); void studentprint(); void scoreInput(); void scoreStat(); void studentStatus(); void bukao(); void tuixue(); void xinmingdan(); void sortAnhao(); void jisuanPingjun(); void tongjiFenshu(); void fenxi();
/* 生成并打印补考通知单*/
/* 生成并打印退学通知单*/
/* 生成并打印新名单*/
/* 按学号排序*/
/* 计算平均分并排序*/
/* 统计分数段*/
/*分析学生成绩,算出不及格门
*/\
数
void mynew(); /* 创新功能*/
void outstudent();
void outdanke();
void teshutuixue();
void main()
{
char choose='\0',yes_no='\0';
do { system("color 4f"); 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');
}
void mainprint()
{ 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");
printf("
|\n");
}
void scoreInput()
{ int i=0;char yes_no='\0';
struct student ex1[N]={0};
FILE *fp=NULL;
system("color 5f");
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].engl ish,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);
}
void scoreStat()
{ char choose='\0',yes_no='\0';
system("color 9f");
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');
}
void sortAnhao()
{ int i=0,j=0,n=0;
struct student ex2[N]={0},temp={0};
FILE *fp=NULL; system("color 9f");
学生基本信息.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;i for(j=i+1;j if(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;i fprintf(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 ish,ex2[i].cprogram,ex2[i].circuit,ex2[i].law); printf("\n 文件已保存至 fclose(fp); } void jisuanPingjun() { int i=0,j=0,n=0; char c='\0'; struct student ex2[N]={0},temp={0}; FILE *fp=NULL; system("color 9f"); 学生基本信息 .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,&e x2[i].cprogram,&ex2[i].circuit,&ex2[i].law); i++; n++; } fclose(fp); for(i=0;i ex2[i].pingjun=(ex2[i].math+ex2[i].english+ex2[i].cprogram+ex2[i].circuit+ex2[i].law)/5; for(i=0;i for(j=i+1;j if(ex2[i].pingjun ex2[i]=ex2[j]; ex2[j]=temp; } 按平均成绩排序 .txt","w"); if(fp==NULL) { printf("\n 打开文件失败! \n"); return; } fprintf(fp," 序号 学号 姓名 高数 英语 编程 电路 法律 平 均\n"); for(i=0;i fprintf(fp,"%3d%15s%16s%7.1f%7.1f%7.1f%7.1f%7.1f%7.1f\n",i,ex2[i].num,ex2[i].name,ex2[i].math,ex2[i ].english,ex2[i].cprogram,ex2[i].circuit,ex2[i].law,ex2[i].pingjun); 按学号排序 .txt\n"); if(fp==NULL) { printf("\n printf("\n 打开文件失败!