C语言课程设计报告--实验设备管理系统--吕浙明
- 格式:doc
- 大小:275.56 KB
- 文档页数:19
C语言课程设计院系:姓名:学号:班号:指导教师:日期:目录一.题目要求 (1)二.需求分析 (1)三.总体设计 (1)四.详细设计 (1)五.完整程序 (12)六.上机操作 (21)七.结束语 (24)一.题目要求实验设备信息包括:设备编号,设备种类(如:微机、打印机、扫描仪等等),设备名称,设备价格,设备购入日期等。
试设计一实验设备信息管理系统,使之能提供以下功能: (1) 能够完成对设备的录入和修改 (2) 对设备进行分类统计 (3) 设备的查询二.需求分析实验室设备信息用文件存储,提供文件的输入输出操作;要能够完成设备的录入和修改,需要提供设备添加和修改操作;实现对设备进行分类统计,需要提供排序操作;实现对设备的插叙需要提供查找操作,设备的查询可根据设备编号、设备种类、设备名称、设备购入日期、正常设备(未报废的)等多种方式查询;另外还要提供键盘式选择菜单以实现功能选择。
三.总体设计根据上面的需求分析,可以将这个系统的设计分为以下模块四.详细设计1.主函数[流程图][程序]main() /*********************主函数***********************************/ {int n,w,t;for(t=0;t<1;t++) 1{do{puts("\t\t*******MENU*******\n\n");puts("\t\t 1.Enter new data");puts("\t\t 2.Addition data");puts("\t\t 3.Modify data");puts("\t\t 4.Statist ");puts("\t\t 5.Search");puts("\t\t 6.Exit");puts("\n\n\t\t*****************\n");printf("What do you want to do(1-6):");scanf("%d",&n);if(n<1||n>6) /*对选择的数字作出判断*/{ w=1;getchar();}else w=0;}while(w==1);switch(n){case 1:t=enter();break; /*输入模块*/case 2:t=enter(); break; /*追加模块*/case 3:t=modifty();break; /*修改模块*/case 4:t=total();break; /*统计模块*/case 5:t=search();break; /*搜索模块*/case 6:exit(0); /*退出*/}}2.各功能模块设计(1)输入模块[流程图][程序]/*********************输入模块*****************************/ 2 int enter() /*输入模块*/{FILE *fp;EQ newequ;int i,j;int c;printf("**************************************\n");printf("Add new equiment\n");printf("**************************************\n");printf("How many equiments do you want to add?\n");scanf("%d",&i); /*输入要输入的设备个数*/for(j=0;j<i;j++){printf("------------------\n");printf("Input equipcode\n");scanf("%s",newequ.equipCode);printf("Input equiptype\n");scanf("%s",newequ.equipType);printf("Input equipname\n");scanf("%s",newequ.equipName);printf("Input equipPrice\n");scanf("%f",&newequ.equipPrice);printf("Input buyYear\n");scanf("%d",&newequ.buyYear);printf("Input buyMonth\n");scanf("%d",&newequ.buyMonth);printf("Input buyDay\n");scanf("%d",&newequ.buyDay);printf("Input scrap\n");scanf("%d",&newequ.scrap);printf("Input scrapYear\n");scanf("%d",&newequ.scrapYear);printf("Input scrapMonth\n");scanf("%d",&newequ.scrapMonth);printf("Input scrapDay\n");scanf("%d",&newequ.scrapDay);if((fp=fopen("test.txt","w"))==NULL) /*打开文件,输入保存*/ {printf("Can not open file!\n");} 3fprintf(fp,"%s %s %s %f %d %d %d %d %d %d %d",newequ.equipCode,newequ.equipType ,newequ.equipName,newequ.equipPrice,newequ.buyYear,newequ.buyMonth,newequ.buyDa y,newequ.scrap,newequ.scrapYear,newequ.scrapMonth,newequ.scrapDay);fclose(fp);printf("\n-----------------------\n");printf("Return to main menu? \n");printf("1.YES \n");printf("2.NO,I want to quit now\n");scanf("%d",&c);if(c==1)return(-1);if(c==2)return(0); /*任务结束选择是返回主菜单还是跳出*/}}(2)追加模块[流程图][程序]/*********************追加模块*****************************/int enter() /*追加模块*/{FILE *fp;EQ newequ;int i,j;int c;printf("**************************************\n");printf("Add new equiment\n");printf("**************************************\n");printf("How many equiments do you want to add?\n");scanf("%d",&i); /*输入要追加的设备个数*/for(j=0;j<i;j++) 4{printf("------------------\n");printf("Input equipcode\n");scanf("%s",newequ.equipCode);printf("Input equiptype\n");scanf("%s",newequ.equipType);printf("Input equipname\n");scanf("%s",newequ.equipName);printf("Input equipPrice\n");scanf("%f",&newequ.equipPrice);printf("Input buyYear\n");scanf("%d",&newequ.buyYear);printf("Input buyMonth\n");scanf("%d",&newequ.buyMonth);printf("Input buyDay\n");scanf("%d",&newequ.buyDay);printf("Input scrap\n");scanf("%d",&newequ.scrap);printf("Input scrapYear\n");scanf("%d",&newequ.scrapYear);printf("Input scrapMonth\n");scanf("%d",&newequ.scrapMonth);printf("Input scrapDay\n");scanf("%d",&newequ.scrapDay);if((fp=fopen("test.txt","w"))==NULL) /*打开文件,输入保存*/ {printf("Can not open file!\n");}fprintf(fp,"%s %s %s %f %d %d %d %d %d %d %d",newequ.equipCode,newequ.equipType ,newequ.equipName,newequ.equipPrice,newequ.buyYear,newequ.buyMonth,newequ.buyDa y,newequ.scrap,newequ.scrapYear,newequ.scrapMonth,newequ.scrapDay);fclose(fp);printf("\n-----------------------\n");printf("Return to main menu? \n");printf("1.YES \n");printf("2.NO,I want to quit now\n");scanf("%d",&c); 5if(c==1)return(-1);if(c==2)return(0); /*任务结束选择是返回主菜单还是跳出*/}}(3)修改模块[需求分析]此模块可以根据客户需要对以记录在文件中的信息进行修改[流程图][程序]/*******************************修改模块*********************/int modifty() /*修改模块*/{EQ equ[50];char code[10];int i,j,c;FILE *fp;printf("*************************************\n");printf("Modifty for the equiment\n");printf("*************************************\n");printf("Please input the equipcode for modiftying\n");scanf("%s",code); /*输入要修改的设备编号*/printf("------------------------------------\n");if((fp=fopen("test.txt","r"))==NULL){ 6 printf("\nCan not open test!\n");}for(i=0;!feof(fp);i++){fscanf(fp,"%s %s %s %f %d %d %d %d %d %d %d",equ[i].equipCode,equ[i].equipType, equ[i].equipName,&equ[i].equipPrice,&equ[i].buyYear,&equ[i].buyMonth,&equ[i].bu yDay,&equ[i].scrap,&equ[i].scrapYear,&equ[i].scrapMonth,&equ[i].scrapDay);if(strcmp(equ[i].equipCode,code)==0){printf("------------------\n");printf("Input new equipcode\n");scanf("%s",equ[i].equipCode);printf("Input new equiptype\n");scanf("%s",equ[i].equipType);printf("Input new equipname\n");scanf("%s",equ[i].equipName);printf("Input equipPrice\n");scanf("%f",&equ[i].equipPrice);printf("Input new buyYear\n");scanf("%d",&equ[i].buyYear);printf("Input new buyMonth\n");scanf("%d",&equ[i].buyMonth);printf("Input new buyDay\n");scanf("%d",&equ[i].buyDay);printf("Input new scrap\n");scanf("%d",&equ[i].scrap);printf("Input new scrapYear\n");scanf("%d",&equ[i].scrapYear);printf("Input new scrapMonth\n");scanf("%d",&equ[i].scrapMonth);printf("Input new scrapDay\n");scanf("%d",&equ[i].scrapDay);}} /*将修改后的信息写如文件中*/fclose(fp);j=i;if((fp=fopen("test.txt","w"))==NULL){printf("\nCan not open test!\n");} 7 for(i=0;i<j;i++){printf("\nwrite!\n");fprintf(fp,"%s %s %s %f %d %d %d %d %d %d %d",equ[i].equipCode,equ[i].equipType ,equ[i].equipName,equ[i].equipPrice,equ[i].buyYear,equ[i].buyMonth,equ[i].buyDa y,equ[i].scrap,equ[i].scrapYear,equ[i].scrapMonth,equ[i].scrapDay);}fclose(fp);printf("\n-----------------------\n");printf("Return to main menu? \n");printf("1.YES \n");printf("2.NO,I want to quit now\n");scanf("%d",&c);if(c==1)return(-1);if(c==2)return(0);}(4)统计模块[需求分析]将已经输入的设备信息进行统计,并显示设备总数、价格总额等信息[流程图][程序]int total(){int c;float sum=0;int count=0;float aver=0;char type[20];EQ equ;int i;FILE *fp;if((fp=fopen("test.txt","r"))==NULL){printf("\nWrong\n");} 8printf("please input equipType:\n");scanf("%s",type);for(i=0;!feof(fp);i++){fscanf(fp,"%s %s %s %f %d % d %d %d %d %d %d",equ.equipCode,equ.equipType,equ.equipName,&equ.equi pPrice,&equ.buyYear,&equ.buyMonth,&equ.buyDay,&equ.scrap,&equ.scrapYe ar,&equ.scrapMonth,&equ.scrapDay);printf("\nOK!\n");printf("%s,%s,%s,%f,%d,%d,% d,%d,%d,%d,%d\n",equ.equipCode,equ.equipType,equ.equipName,equ.equipP rice,equ.buyYear,equ.buyMonth,equ.buyDay,equ.scrap,equ.scrapYear,equ. scrapMonth,equ.scrapDay);if(strcmp(equ.equipType,typ e)==0){count++;sum+=equ.equipPrice;aver=sum/count;}}fclose(fp);printf("----------Statist--Result-----------");printf("\n\nthe number of this type is:%d",count);printf("\n\nthe total sum of price is:%f",sum);printf("\n\nthe aver of total price is:%f",aver);printf("\nPress any key to exit......");getch();printf("\n-----------------------\n");printf("Return to main menu? \n");printf("1.YES \n");printf("2.NO,I want to quit now\n");scanf("%d",&c);if(c==1)return(-1);if(c==2)return(0);}(5)搜索模块9[需求分析]该模块的功能是查找用户需要的对应记录,可以分别根据设备编号、设备种类、设备名称、设备购入日期、正常设备(未报废的)等多种方式查询。
二○一五~二○一六学年第一学期电子与信息工程系课程设计报告书课程名称:程序设计基础实践班级:学号:姓名:指导教师:二○一五年十二月1..实验室设备信息管理系统功能(1). 每一条记录包括实验室的设备编号、设备名称、设备型号、设备价格、设备购买日期信息。
(2). 实验设备信息录入:可以一次完成诸多条记录的录入。
(3). 实验设备信息更改:可实现对实验设备信息更改的信息进行适当的修改。
(4). 报废设备信息删除:对实验损毁设备信息予以删除。
(5). 实验设备信息查询:本系统提供两种查询实验设备的方法:1.按器材名称查询.2.按器材编号查询.从而完成按实验设备的查找查找功能,并显示。
(6). 实验设备信息排序:根据实验设备的编号进行排序,以实现实验设备的有序全局查看。
实验设备信息显示功能:完成全部学生记录的显示。
(7). 简单帮助:提供实验室负责人简单的信息。
(8). 保存功能:将学生记录保存在任何自定义的文件中,如保存在:c:\score。
(9). 读取功能:将保存在文件中的学生记录读取出来。
(10). 有一个清晰美观界面来调用各个功能2.设计内容2.1 程序的总体设计整个系统除了主函数外,另外还有11个函数,实现以下功能:实验室设备录入功能、显示功能、查找功能、排序功能、读出与写入取功能。
各个函数的详细设计说明分别如下:2.2 数据结构使用C语言创建的结构体如下:typedef Equipment /*定义数据结构*/{char bianhao; //编号char name[20]; //名称char model[20]; //型号bnmchar price[20]; //价格char buy_date[20]; //购买日期};3 详细设计3.1实验设备管理系统主程序模块设计控制整个程序的运行,通过主函数模块分别调用各个模块,实现各项功能,流程如图1所示。
通过switch进入分支结构从而调用执行不同的函数,以实现菜单选择的功能。
西安郵電大學C语言课程设计报告书学院名称计算机学院学生姓名吴戌睿专业名称网络工程班级1201班学号04122030指导教师陈皓2013年06月03日至时间2013年06月12日实验题目:学生宿舍管理系统一、实验目的通过本课程设计,强化上机动手能力,使学生在理论和实践的基础上进一步巩固《C 语言程序设计》课程学习的内容,掌握工程软件设计的基本方法。
通过这次实习练习,可以更进一步的熟悉所学的知识,还可以加强和巩固知识。
长达两周的上机练习,为我们提供了很好的编程环境。
更好的了解编程的意义,为将来参加实践活动以及以后的毕业设计打下坚实的基础。
二、实验内容我设计的是“车辆管理系统”,主要是针对车辆信息的管理,适用对象主要是需要统一管理的车辆,例如租车公司。
包括车辆的序号,车牌,品牌,车主信息。
在编写过程中主要运用C语言的基本知识有:数据类型(整形、实型、字符型、指针、数组、结构等);运算类型(算术运算、逻辑运算、自增自减运算、赋值运算等);程序结构(顺序结构、判断选择结构、循环结构);大程序的功能分解方法(即函数的调用与使用)等。
三、需求分析该程序是由C语言编写的一个车辆管理查询软件,本程序在Microsoft Visual C++ 6.0下运行,其主要功能是实现对车辆信息的录入、添加、删除、修改、查询、统计。
其中查询可以分别以序号,车牌号为关键字查询车辆信息。
四、概要设计1、方案设计2、数据结构说明程序中数据主要是学生信息,具体属于类型如下:struct car{int num; /*序号*/char chepai[10]; /*车牌号*/ char trademark[10]; /*品牌*/ char name[20]; /*车主姓名*/ char call[20]; /*联系方式*/ struct car *next;};3、模块功能说明第一密码模块:调用mima(),进行初始登陆,管理者的注册与登录操作。
C语言课程设计报告—实验设备管理系统C语言程序设计报告一课程设计的目的提高程序设计能力,检验课堂教学内容,掌握程序设计的基本方法和调试技能。
二课程设计报告正文1 课程设计题目的原文;实验设备信息包括:设备编号、设备种类(如:微机打印机扫描仪等等)、设备名称、设备价格、设备购入日期、是否报废、报废日期等。
试设计一实验设备信息管理系统,使之能提供以下功能:(1)能够完成对设备的录入和修改(2)对设备进行分类统计(3)设备的查询2 需求分析实验室设备信息用文件存储,提供文件的输入输出操作;要能够完成设备的录入和修改,需要提供设备添加和修改操作;实现对设备进行分类统计,需要提供排序操作;实现对设备查询需要提供查找操作,设备的查询可根据设备编号设备种类设备购入日期正常设备(未报废的)等多种方式查询;另外还要根据键盘式选择菜单以实现功能选择。
3总体设计与模块的划分整个系统可设计为实验设备信息输入模块实验设备信息添加模块实验设备信息修改模块实验设备分类统计模块和实验设备查询模块。
4 建立实验设备信息结构体,结构体成员包括设备编号设备种类设备名称设备价格设备购入日期是否报废报废日期。
实验设备管理系统设计实验实验实验实验实验功能设备设备设备设备设备选择信息信息信息分内查询输入添加修改统计模块模块模块模块模块4 详细设计A 主函数void main(){Node *equip;FILE *fp;int flag;Node *p,*q;printf("\t\t\t\t设备管理系统\n");equip=(Node*)malloc(sizeof(Node)); equip->next=NULL; 开始 p=equip;fp=fopen("设备管理系统","wb+");显示一系列功能选择 q=(Node*)malloc(sizeof(Node));if(fread(q,sizeof(Node),1,fp)) //将文件的内容放入接点中{N q->next=NULL; 输入n,判断m p->next=q; 是否是0到4, p=q; //将该接点挂入链表中}fclose(fp); //关闭文件根据n值调用各 while(1) 功能模块函数 {printf("***********************目录********************************");结束 printf("\n1添加记录\n");printf("\n2修改记录\n");printf("\n3显示记录\n");printf("\n4统计分类记录\n");printf("\n0*-EXIT-*\n");printf("请输入你要操作的序号:");scanf("%d",&flag);switch(flag){case 0: printf("\n>>>>>>>>>>提示:已经退出系统,ByeBye!\n");break; case 1: Add(equip); break; //增加记录case 2: Modify(equip); break;//修改记录case 3: Disp(equip); break;//显示记录信息case 4: Tongji(equip); break;//统计记录default: printf("\n>>>>>>>>>>提示:输入错误!\n"); break; }}}B 各功能模块设计(1)输入模块Struct shebei{ char ID[10]; char name[15]; char kind[15]; char over[15]; char yesno[10]; char time[10];char price[10];};(2)追加模块void Add(Node *equip) //添加记录{Node *p,*r,*s;char id[10]; //先用于输入ID,也用于判断是否跳出循环r=equip;s=equip->next; //使s为第一个有用的结点while(r->next!=NULL) //这个循环的作用是使r为最后一个有用的结点 r=r->next; //将指针置于最末尾开始 while(1){输入ID号,并将指针置于最末printf(">>>>>>>>>>提示:输入0则返回主菜单!\n");尾 printf("\n请你输入设备ID号:");scanf("%s",id);if(strcmp(id,"0")==0) break; p=(Node *)malloc(sizeof(Node)); //申请空间依次输入shebei 结构体内容,strcpy(p->data.ID,id); 完成一条添加记录 printf("\n请输入设备名称:");scanf("%s",p->); printf("\n请输入设备种类:");提示以完成一条记录添加 scanf("%s",p->data.kind); printf("\n请输入报废日期:");scanf("%s",&p->data.over); printf("\n请输入设备是否报废:");scanf("%s",&p->data.yesno); 结束 printf("\n请输入设备购买时间:");scanf("%s",&p->data.time); printf("\n请输入设备价格:");scanf("%s",&p->data.price); printf(">>>>>>>>>>提示:已经完成一条记录的添加。
C 语言课程实习报告仪器仪表管理系统仪器仪表信息管理系统1.题目与题目分析2.主函数3.菜单函数4.功能模块(1)输入模块(2)添加模块(3)修改模块(4)删除模块(5)浏览模块(6)查找模块5.公共函数6.操作结果7.总结与心得1.仪器仪表信息管理系统题目与题目分析题目:仪器仪表管理[要求]系统功能的基本要求:⑴新的仪器仪表信息的录入;⑵在借出、归还、维修时对仪器仪表信息的修;⑶对报废仪器仪表信息的删除;⑷按照一定的条件查询、统计符合条件的仪器仪表信息;查询功能至少应该包括仪器仪表基本信息的查询、按时间段(如在2004年1月1日到2004年10月10日购买、借出的仪器仪表等)查询、按时间点(借入时间,借出时间,归还时间)查询等,统计功能至少包括按时间段(如在2004年1月1日到2004年10月10日购买、借出的仪器仪表等)统计、按仪器仪表基本住处的统计等;⑸对查询、统计的结果打印输出。
需求分析根据题目要求,由于仪器仪表信息是存放在文件中,所以应提供文件的输入、输出等操作;在程序中需要浏览仪器仪表的信息,应提供显示、查找、删除、添加、修改等操作;另外还提供键盘式选择菜单实现功能选择。
总体设计根据上面的需求分析,可以将这个系统的设计分为以下几个模块:输入模块、添加模块、修改模块、删除模块、查找模块、浏览模块详细设计2. 主函数主函数设计比较简单,只有一个函数调用,被调用的函数提供输入,处理和输出部分的函数调用。
其中各功能模块用菜单方式选择。
此函数为菜单函数,执行完每部分模块后能够方便返回到系统界面。
int main( ){ menu();}3.菜单函数菜单函数的主要结构用流程图表示如下:程序:void menu(){ int n,w;do{puts("\t\t*****************仪表仪器信息管理系统**********************\n\n");puts("\t\t\t\t 经济管理学院喻骏斯学号:20081003064");puts("\t\t\t\t 1.仪器信息录入");puts("\t\t\t\t 2.添加新的仪器");puts("\t\t\t\t 3.修改仪器信息");puts("\t\t\t\t 4.删除仪器信息");puts("\t\t\t\t 5.查询仪器信息");puts("\t\t\t\t 6.浏览");puts("\t\t\t\t 7.退出 ");puts("\n\n\t\t********************我是分界线********************\n");printf("选择您需要的服务(1-7):[ ]\b\b");scanf("%d",&n);if(n<1||n>7){ w=1;getchar();}else w=0;}while(w==1);switch(n){ case 1:enter();break;case 2:add();break;case 3:modify();break;case 4:del();break;case 5:search();break;case 6:browse();break;case 7:exit(0);}}4.功能模块(1)输入模块仪器仪表信息采用结构体变量类型存放,成员包括仪器名称、编号、购买时间、供稿时间、伸出时间、归还时间、维修时间、状态信息(0代表可借出,1代表已借出,2代表正在维修,-1代表删除).程序:void enter(){ int i,n;printf("您要输入的仪器数量(1-%d)?",N);scanf("%d",&n);printf("\n 请输入相关信息\n\n");for(i=0;i<n;i++){ printf("\n 输入第%d台仪器的信息.\n",i+1);input(i);}if(i!=0) save(n);menu();}(2)添加模块该模块的功能是用户需要增加新的仪器记录,请从键盘输入并逐条写到原来的输入文件中,采用追加方式打开文件。
实验设备管理系统c语言版精选文档TTMS system office room 【TTMS16H-TTMS2A-TTMS8Q8-4 .主要代码段分析(1).添加模块主要是实现设备的添加,输入添加的设备个数,然后用for循环语句,循环次数是你输入的设备个数。
循环输出设备的编号,种类名称,用fopen打开文件,w写方式实现首次添加。
int addition() /*添加模块*/{EquInfo news[50];int i,j,c;FILE *fp;system("cls");printf("你想输入多少个设备\n");scanf("%d",&i); /*输入要添加的设备个数*/for(j=0;j<i;j++){ printf("------------------\n");printf("输入设备编号\n");scanf("%s",&news[j].equipCode);printf("输入设备种类\n");scanf("%s",news[j].equipType);……if((fp=fopen("","w"))==NULL) /*打开文件,输入保存*/{printf("不能打开文件!\n");}for (j=0;j<i;j++){ fprintf(fp,"%s %s %s %f %s %d %s",news[j].equipCode,news[j].equipType,news[j].equipName,news[j].equip Price,news[j].buyDate,news[j].scrap,news[j].scrapDate); }fclose(fp);printf("\n-----------------------\n");printf("返回主菜单 \n");printf("1.是\n");printf("2.不,退出\n");scanf("%d",&c);if((fp=fopen("","a"))==NULL)quipCode,newequ[j].equipType,newequ[j].equipName,newequ[j].equip Price,newequ[j].buyDate,newequ[j].scrap,newequ[j].scrapDate);}fclose(fp);四、调试过程(1 .测试数据设计 2 .测试结果分析)(1)测试数据设计:进入主菜单:根据需求操作,按“1”添加信息,以便测试设备个数:2设备编号:1设备各类:abc设备名称:switch设备价格:90购买日期:是否报废:0报废日期:0(2)测试结果分析:1.主菜单函数:根据需求输入相应的操作主菜单2.添加模块:当输入1后,进入添加页面,对设备的各方面信息进行添加添加设备添加后文本中的数据3.修改模块:输入您需要修改的设备编号,如果输入的编号与查找不相同将真的提示返回菜单或退出,正确进入如下键面修改设备信息修改后文本中的信息4.追加模块:输入您需要追加的设备个数,进行设备信息的添加,进入如下所示追加设备追加后文件中的数据5.统计模块:输入设备类型,进行设备信息的统计,进入如下所示分类统计6.搜索模块:选择你需要搜索的方式,可以按编号搜索,也可以按设备名搜索,还可以按设备价格搜索,如下所示按编号搜索按价格搜索按设备名搜索7.退出模块:选择5直接退出系统退出五、总结1 .设计中遇到的问题及解决过程文本中会出现乱码,但不是所有数据都就乱码,而是文件是的其中某一项是乱码,应该不是fread与fprint的问题,后来发现我定义的是char字符串类型,但在输入数据时scanf("%d",&equ[i].buyDate);用的是%d的格式输入。
C语言大型作业实践报告计算机1001制作者:李菁华张兆丰秦恒加2011年6月题目:选修课程管理系统要求:假定有N门选修课,每门课有课程编号、名称、课程性质、总学时、授课学时、实验或上机学时、学分、开课学期等信息。
学生可按要求(如总学分不能少于20学分)选课。
▪课程信息维护,如录入、修改、删除等,课程信息用文件保存。
▪课程信息浏览—输出。
▪学生选课功能。
▪查询功能包括:按学分、课程性质、学生等查询。
▪统计功能。
统计各门课程的选修人数。
▪本系统要有通用性、界面美观、操作方便。
要考虑系统安全。
具体算法流程设计思路(流程图):程序源代码:#include<stdio.h>#include<time.h>#include<string.h>#include<conio.h>main(){intx,xi,choice2,choice3,choice4,choice8,q=0,filein=0,limit=0,i,num,tonum,tcnum,ecnum ,score,term,student,A,io=0,screen=0;/*-----变量定义区-----,x为现有选修课数量,目前不能超过10,后续与主程序合并时移动到定义区,xi为选修课信息录入循环变量*/char choice1,choice5,choice6,choice7,name[10],kind[10];int carenum[10]={0,0,0,0,0,0,0,0,0,0}; /*用于统计每门课程选修人数*/int o,change=0,delatenum,e,u,stui=0,stuc=0;struct elective /*选修课程信息结构体*/{int electivenum; /*选修课编号*/char electivename[10]; /*选修课课名*/char electivekind[10]; /*选修课性质,暂定考试考查之分*/int totalclassnum; /*总课时*/int techclassnum; /*授课课时*/int expclassnum; /*实验课时*/int credits; /*学分*/int classterm; /*开课学期*/int students; /*此门课选修人数*/};struct muticlass /*学生选择的课程信息结构体*/{int stuchoice;int stuclassnum;char stuclassname;};struct student /*学生信息结构体*/{char stuname[10];long stunum;int stucredits;struct muticlass mutichoice[20]; /*暂定每名学生最多选20门课*/ /*本结构体为嵌套结构体,完善功能时请注意嵌套结构*/};struct student studentcare[100]; /*暂定最多可以有100名学生选课*/struct elective electivedata[10]; /*最多10门选修课*/FILE *electivefp; /*选修课程信息文件指针*/FILE *stufp; /*学生信息文件指针*/FILE *outfp; /*课程信息输出文件指针*/FILE *find;long now,midkey; /*now为密码算法中间变量,midkey为密码算法最终结果*/int chancenum=0,m; /*chancenum为输入密码错我次数计数变量,m为主目录选择判断变量*/unsigned long password,password2;struct tm *timenow; /*timenow为标准系统时间提取指针*/textcolor(WHITE);system("cls");gotoxy(20,12);cprintf("Welcome to the Elective management system"); /*一级主菜单*/gotoxy(1,24);system("pause");t2:system("cls");gotoxy(24,11);cprintf("1.Students elective course system");gotoxy(24,12);cprintf("2.Elective information output");gotoxy(24,13);cprintf("3.Elective course information searching");gotoxy(24,14);cprintf("4.I'm the administrator!");gotoxy(24,15);cprintf("5.Exit the system");gotoxy(24,16);scanf("%d",&choice8);switch(choice8){case 1: limit=0;goto students1;case 2: goto x11;case 3: goto x12;case 4: goto x7;case 5: goto x3;default: system("cls");gotoxy(20,12);cprintf("wrongchoice");gotoxy(1,24);system("pause");goto t2;}x7:textcolor(YELLOW); /*-----密码判断模块-----*/time(&now);midkey=now;midkey=midkey/100;password=midkey;return2:system("cls");gotoxy(22,15);cprintf("Enter 1 to refresh the password.");gotoxy(25,12);cprintf("Please enter your password\n");gotoxy(25,13);scanf("%ld",&password2); /*password2为用户输入的密码变量*/ if(chancenum<4) /*用户输入密码错误次数判断*/{if(password2==password){limit=1;goto x4;}else{if(password2==1){goto x7;}else{system("cls");gotoxy(22,12);textcolor(RED);cprintf("password error");gotoxy(18,13);cprintf("please enter the right password");gotoxy(20,14);cprintf("You have only %d chances",3-chancenum);gotoxy(1,24);system("pause");if(chancenum==3) /*连续4次输入错误密码判断*/{goto x6;}chancenum=chancenum+1;goto return2;}}}x6:system("cls");gotoxy(20,12);cprintf(" Sorry,you have null chance.");gotoxy(1,24);goto x5; /*-----密码判断模块结束-----*/x4:switch(limit){case 0: textcolor(YELLOW);goto students1;case 1: textcolor(GREEN);goto t3;default: textcolor(RED);system("cls");gotoxy(20,12);cprintf("None Limited");gotoxy(1,24);system("pause");textcolor(WHITE);goto t2;}t3:textcolor(GREEN); /*-----主程序开始-----*/system("cls");gotoxy(20,12);cprintf("Welcome to the Elective management system"); /*一级主菜单*/gotoxy(1,24);system("pause");return1:system("cls");gotoxy(24,3);cprintf("Elective management system"); /*选修课管理系统*/gotoxy(24,11);cprintf("1.Students elective course system."); /*学生选课系统*/gotoxy(24,12);cprintf("2.Elective course maintenance system."); /*课程信息维护系统*/gotoxy(24,13);cprintf("3.Exit the system."); /*退出系统*/gotoxy(24,14);scanf("%d",&o);switch(o){case 1: goto students1;case 2: goto electivemans1;case 3: goto x3;default: system("cls");gotoxy(12,12);cprintf("error choice,please make your choice again\n");gotoxy(1,24);system("pause");goto return1;}electivemans1:system("cls");change=0;gotoxy(24,3);cprintf("Elective management system"); /*二级主菜单*/gotoxy(24,11);cprintf("1.New elective database"); /*新建选修课程信息*/gotoxy(24,12);cprintf("2.Maintain elective database"); /*修改选修课程信息*/gotoxy(24,13);cprintf("3.Show the number of statistical electives"); /*统计每门课程选修人数*/gotoxy(24,14);cprintf("4.Elective information output"); /*课程信息输出*/gotoxy(24,15);cprintf("5.Return to the main menu"); /*返回主菜单*/gotoxy(24,16);scanf("%d",&m);switch(m) /*主目录跳转判断*/{case 1: goto x1;case 2: goto x2;case 3: goto x8;case 4: goto x11;case 5: goto return1;default: system("cls");gotoxy(12,12);cprintf("error choice,please make your choice again\n");gotoxy(1,24);system("pause");goto electivemans1;}x3:system("cls");gotoxy(25,12);cprintf("Thanks for using thissystem");gotoxy(1,24);goto x5;x1:electivefp=fopen("elective.dat","w+"); /*-----选修课程信息新建模块-----*/ if((electivefp=fopen("elective.dat","w+"))==NULL){gotoxy(12,12);cprintf("connot open this file");gotoxy(11,13);cprintf("Please debug this program");gotoxy(12,17);system("pause");goto z1;}system("cls");gotoxy(12,12);cprintf("Please according to clew input elective course information");gotoxy(1,24);system("pause");a1:system("cls");gotoxy(12,12);cprintf("Please input the elective quantity,Up to 10."); /*输入此次录入选修课程门数*/gotoxy(14,13);scanf("%d",&x); /*输入选修课总课程数*/if(x>10) /*总课程数小于10判断*/{system("cls");gotoxy(12,12);cprintf("Up to 10");gotoxy(1,24);system("pause");goto a1;}for(xi=0;xi<x;xi++) /*课程信息录入*/{r1:system("cls"); /*课程信息开始录入*/gotoxy(12,11);cprintf("Please enter the No.%d elective course numbers",xi+1);gotoxy(12,12);scanf("%d",&electivedata[xi].electivenum);if(q==1){goto z4;}r2:system("cls");gotoxy(12,11);cprintf("Please input the name of the No.%d elective course class",xi+1);gotoxy(12,12);scanf("%s",&electivedata[xi].electivename);if(q==1){goto z4;}r3:system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective properties,\"exam\" or \"examines\"",xi+1);gotoxy(12,12);scanf("%s",&electivedata[xi].electivekind);if(q==1){goto z4;}r4:system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective total class number",xi+1);gotoxy(12,12);scanf("%d",&electivedata[xi].totalclassnum);if(q==1){goto z4;}r5:system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective lecture class number",xi+1);gotoxy(12,12);scanf("%d",&electivedata[xi].techclassnum);if(q==1){goto z4;}r6:system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective the experiment class number",xi+1);gotoxy(12,12);scanf("%d",&electivedata[xi].expclassnum);if(q==1){goto z4;}r7:system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective credits",xi+1);gotoxy(12,12);scanf("%d",&electivedata[xi].credits);if(q==1){goto z4;}r8:system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective course semesters",xi+1);gotoxy(12,12);scanf("%d",&electivedata[xi].classterm);if(q==1){goto z4;}if(xi<(x-1)){system("cls");gotoxy(12,12);cprintf("This elective information recorded success, please enter the next");gotoxy(1,24);system("pause");}} /*课程信息录入结束*/z4:system("cls"); /*课程信息输入正确性判断*/gotoxy(12,12);cprintf("If information recorded correctly?");gotoxy(14,13);cprintf("Enter \"y\" for Yes,\"n\" for No");gotoxy(14,14);scanf("%c",&choice1);switch(choice1){case 121: goto z2;case 110: goto z3;default: system("cls");gotoxy(12,12);cprintf("Wrong choicePlease make it again.");gotoxy(1,24);system("pause");goto z4;}z3:{ /*错误信息定位*/system("cls");gotoxy(8,5);cprintf("What message entry errors?");gotoxy(12,6);cprintf("1.elective course numbers");gotoxy(12,7);cprintf(" of elective course class");gotoxy(12,8);cprintf("3.elective properties");gotoxy(12,9);cprintf("4.elective total class number");gotoxy(12,10);cprintf("5.elective lecture class number");gotoxy(12,11);cprintf("6.elective experiment class number");gotoxy(12,12);cprintf("7.elective credits");gotoxy(12,13);cprintf("8.elective course semesters");gotoxy(12,14);cprintf("9.Add a elective course lesson.");gotoxy(12,15);cprintf("10.Delate a elective course lesson.");gotoxy(12,16);scanf("%d",&choice2); /*错误项目定位*/system("cls");if(choice2==9){goto r9;}elseif(choice2==10){goto r10;}else{goto z6;}z6:system("cls");gotoxy(12,12);cprintf("Which group of curriculum information need to modify?"); gotoxy(12,13);scanf("%d",&choice3); /*错误组别定位*/if(choice3<x+1&&choice3>0){goto z7;}else{system("cls");gotoxy(12,12);cprintf("Wrong group,please enter again");gotoxy(1,24);system("pause");goto z6;}z7:xi=choice3-1;switch(choice2) /*错误信息修改*/{case 1: q=1;goto r1;case 2: q=1;goto r2;case 3: q=1;goto r3;case 4: q=1;goto r4;case 5: q=1;goto r5;case 6: q=1;goto r6;case 7: q=1;goto r7;case 8: q=1;goto r8;case 9: q=1;goto r9;case 10: q=1;goto r10;default: system("cls");gotoxy(12,12);cprintf("Wrong choice.Please make it again.");gotoxy(1,24);system("pause");goto z3;}}z2:if(change==0){goto write1;}else{remove("elective.dat");electivefp=fopen("elective.dat","w+");goto write1;}write1:fprintf(electivefp,"%d \n",x);for(xi=0;xi<x;xi++) /*将完善的课程信息以文件的形式保存在磁盘上*/{electivedata[xi].students=0;fprintf(electivefp,"%d %s %s %d %d %d %d %d %d\n",electivedata[xi].electivenu m,electivedata[xi].electivename,electivedata[xi].electivekind,electivedata[xi].totalcla ssnum,electivedata[xi].techclassnum,electivedata[xi].expclassnum,electivedata[xi].cr edits,electivedata[xi].classterm,electivedata[xi].students);}filein=1;z1:{system("cls");gotoxy(12,12);cprintf("Elective course information input success!");gotoxy(1,24);system("pause");}goto return1; /*返回主菜单*/x2:change=1;if(filein==1){goto z3;}electivefp=fopen("elective.dat","r+");fscanf(electivefp,"%d \n",&x);for(xi=0;xi<x;xi++){fscanf(electivefp,"%d %s %s %d %d %d %d %d %d\n",&electivedata[xi].electiven um,&electivedata[xi].electivename,&electivedata[xi].electivekind,&electivedata[xi].t otalclassnum,&electivedata[xi].techclassnum,&electivedata[xi].expclassnum,&electiv edata[xi].credits,&electivedata[xi].classterm,&electivedata[xi].students);}goto z3;r9:x=x+1;system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective course numbers",x);gotoxy(12,12);scanf("%d",&electivedata[x-1].electivenum);system("cls");gotoxy(12,11);cprintf("Please input the name of the No.%d elective course class",x);gotoxy(12,12);scanf("%s",&electivedata[x-1].electivename);system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective properties,\"exam\" or \"examines\"",x);gotoxy(12,12);scanf("%s",&electivedata[x-1].electivekind);system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective total class number",x);gotoxy(12,12);scanf("%d",&electivedata[x-1].totalclassnum);system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective lecture class number",x);gotoxy(12,12);scanf("%d",&electivedata[x-1].techclassnum);system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective the experiment class number",x); gotoxy(12,12);scanf("%d",&electivedata[x-1].expclassnum);system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective credits",x);gotoxy(12,12);scanf("%d",&electivedata[x-1].credits);system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective course semesters",x);gotoxy(12,12);scanf("%d",&electivedata[x-1].classterm);goto z4;r10:system("cls");gotoxy(12,12);cprintf("Which group of elective do you want to delate?");gotoxy(12,13);scanf("%d",&delatenum);if(delatenum>0||delatenum<x){for(e=0;e<x-delatenum;e++){electivedata[delatenum+e-1]=electivedata[delatenum+e];}x=x-1;remove("elective.dat");electivefp=fopen("elective.dat","w+");}else{system("cls");gotoxy(12,12);cprintf("we do not have that group of elective information");gotoxy(1,24);system("pause");goto r10;}goto z4;students1:{electivefp=fopen("elective.dat","r+");fscanf(electivefp,"%d \n",&x);for(xi=0;xi<x;xi++){fscanf(electivefp,"%d %s %s %d %d %d %d %d %d\n",&electivedata[xi].electivenum, &electivedata[xi].electivename,&electivedata[xi].electivekind,&electivedata[xi].total classnum,&electivedata[xi].techclassnum,&electivedata[xi].expclassnum,&electiveda ta[xi].credits,&electivedata[xi].classterm,&electivedata[xi].students);}stufp=fopen("stu.dat","r+");return4:system("cls");gotoxy(12,12);cprintf("Please enter your name");gotoxy(12,13);scanf("%s",&studentcare[stui].stuname);system("cls");gotoxy(12,12);cprintf("Please enter your student ID");gotoxy(12,13);scanf("%ld",&studentcare[stui].stunum);care2:system("cls");gotoxy(3,2);cprintf("Existing elective");for(u=0;u<x;u++){gotoxy(5,u+3);cprintf("%d.num:%dname:%s\n",u+1,electivedata[u].electivenum,electivedata[u].electivename);}gotoxy(5,x+4);cprintf("Which are you interested?");gotoxy(5,x+5);scanf("%d",&choice4);return3:system("cls");gotoxy(3,2);cprintf("Elective information");gotoxy(4,4);cprintf("Num:%d",electivedata[choice4-1].electivenum);gotoxy(4,5);cprintf("Name:%s",electivedata[choice4-1].electivename);gotoxy(4,6);cprintf("Kind:%s",electivedata[choice4-1].electivekind);gotoxy(4,7);cprintf("Total class:%d",electivedata[choice4-1].totalclassnum);gotoxy(4,8);cprintf("Tech class:%d",electivedata[choice4-1].techclassnum);gotoxy(4,9);cprintf("Exp class:%d",electivedata[choice4-1].expclassnum);gotoxy(4,10);cprintf("Credits:%d",electivedata[choice4-1].credits);gotoxy(4,11);cprintf("Class term:%d",electivedata[choice4-1].classterm);gotoxy(4,14);cprintf("Sure to choose this course? enter \"y\" for yes,\"n\" for no");gotoxy(4,15);scanf("%c",&choice5);switch(choice5){case 121: goto care1;case 110: goto care2;default: system("cls");gotoxy(12,12);cprintf("wrong choice");goto return3;}care1:if(stuc>0){for(xi=0;xi<stuc+1;xi++){if(choice4==studentcare[stui].mutichoice[xi].stuclassnum){system("cls");gotoxy(12,12);cprintf("Connot repeat courses");gotoxy(1,24);system("pause");goto care2;}}}carenum[choice4-1]++;electivedata[choice4-1].students=carenum[choice4-1];studentcare[stui].mutichoice[stuc].stuchoice=choice4;studentcare[stui].stucredits=studentcare[stui].stucredits+electivedata[choice4-1 ].credits;studentcare[stui].mutichoice[stuc].stuclassnum=electivedata[choice4-1].elective num;studentcare[stui].mutichoice[stuc].stuclassname=electivedata[choice4-1].electiv ename;x10:system("cls");gotoxy(12,12);cprintf("Course whether end? enter \"y\" for yes,\"n\" for no");gotoxy(12,13);scanf("%c",&choice6);switch(choice6){case 121: goto x9;case 110: stuc++;goto care2;default: system("cls");gotoxy(12,12);cprintf("wrongchoice");gotoxy(1,24);system("pause");goto x10;}x9:if(studentcare[stui].stucredits<20){system("cls");gotoxy(12,12);cprintf("Attention!Total credits less than 20!");gotoxy(1,24);system("pause");goto x10;}else{remove("stu.dat");stufp=fopen("stu.dat","a+");fprintf(stufp,"%d \n",stui);system("cls");gotoxy(12,12);cprintf("Elective success!");gotoxy(1,24);system("pause");return6:system("cls");gotoxy(12,12);cprintf("If others need courses? enter \"y\" for yes,\"n\" for no");gotoxy(12,13);scanf("%c",&choice7);switch(choice7){case 121: stui++;goto return4;case 110: goto return5;default: system("cls");gotoxy(12,12);cprintf("wrong choice");gotoxy(1,24);system("pause");goto return6;}return5: for(u=0;u<stui+1;u++){fprintf(stufp,"%s %ld %d\n",studentcare[u].stuname,studentcare[u].stunum,studentcare[u].stucredits);for(xi=0;xi<stuc+1;xi++){fprintf(stufp,"%d %d %s\n",studentcare[u].mutichoice[xi].stuchoice,studentcare[u].mutichoice[xi].stuclassnu m,studentcare[u].mutichoice[xi].stuclassname);}}remove("elective.dat");electivefp=fopen("elective.dat","w+");fprintf(electivefp,"%d \n",x);for(xi=0;xi<x;xi++) /*将完善的课程信息以文件的形式保存在磁盘上*/{fprintf(electivefp,"%d %s %s %d %d %d %d %d %d\n",electivedata[xi].electivenum,el ectivedata[xi].electivename,electivedata[xi].electivekind,electivedata[xi].totalclassnu m,electivedata[xi].techclassnum,electivedata[xi].expclassnum,electivedata[xi].credits ,electivedata[xi].classterm,electivedata[xi].students);}switch(limit){case 1: goto return1;case 0: goto t2;default: goto t2;}}}x8:electivefp=fopen("elective.dat","r+");fscanf(electivefp,"%d \n",&x);for(xi=0;xi<x;xi++){fscanf(electivefp,"%d %s %s %d %d %d %d %d %d\n",&electivedata[xi].electivenum, &electivedata[xi].electivename,&electivedata[xi].electivekind,&electivedata[xi].total classnum,&electivedata[xi].techclassnum,&electivedata[xi].expclassnum,&electiveda ta[xi].credits,&electivedata[xi].classterm,&electivedata[xi].students);}system("cls");gotoxy(3,4);cprintf("Elective toll");for(u=0;u<x;u++){gotoxy(3,u+6);cprintf("%s : %d",electivedata[u].electivename,electivedata[u].students);}gotoxy(1,18);system("pause");goto electivemans1;x11:system("cls"); /*-----查找模块-----*/electivefp=fopen("elective.dat","r+");fscanf(electivefp,"%d \n",&x);for(xi=0;xi<x;xi++){fscanf(electivefp,"%d %s %s %d %d %d %d %d %d\n",&electivedata[xi].electivenum, &electivedata[xi].electivename,&electivedata[xi].electivekind,&electivedata[xi].total classnum,&electivedata[xi].techclassnum,&electivedata[xi].expclassnum,&electiveda ta[xi].credits,&electivedata[xi].classterm,&electivedata[xi].students);}outfp=fopen("electiveinformation.doc","w+");fprintf(outfp,"选修课程信息\n\n\n\n");for(xi=0;xi<x;xi++){fprintf(outfp,"课程编号:%d \n课程名:%s \n课程种类:%s \n总课时:%d \n教学课时:%d \n实验课时:%d \n学分:%d \n开课学期:%d \n已选人数:%d\n\n\n",electivedata[xi].electivenum,electivedata[xi].electivename,electivedat a[xi].electivekind,electivedata[xi].totalclassnum,electivedata[xi].techclassnum,electiv edata[xi].expclassnum,electivedata[xi].credits,electivedata[xi].classterm,electivedata [xi].students);}switch(limit){case 1: goto electivemans1;case 0: goto t2;default: goto t2;}x12:{find=fopen("elective.dat","r+");fscanf(find,"%d \n",&x);for(i=0;i<x;i++){fscanf(find,"%d %s %s %d %d %d %d %d %d\n",&electivedata[i].electivenum,&el ectivedata[i].electivename,&electivedata[i].electivekind,&electivedata[i].totalclassnu m,&electivedata[i].techclassnum,&electivedata[i].expclassnum,&electivedata[i].credi ts,&electivedata[i].classterm,&electivedata[i].students);}xx:io=0;system("cls");gotoxy(7,3);printf("a:search by electivenum;\n b:search by electivename;\nc:search by electivekind;\n d:search by totalclassnum;\n e:search by techclassnum;\n f:search by expclassnum;\n g:search by credits;\n h:search by classterm;\n i:search by students\n");gotoxy(7,12);cprintf("j:Return to the main menu");gotoxy(7,13);scanf("%c",&A);switch(A){case 97: goto a;case 98: goto b;case 99: goto c;case 100: goto d;case 101: goto e;case 102: goto f;case 103: goto g;case 104: goto h;case 105: goto i;case 106: goto t2;default: system("cls");gotoxy(24,12);cprintf("wrongchoice\n");system("pause");goto xx;}a:screen=0;{system("cls");gotoxy(24,12);cprintf("Please write down the electivenum\n");gotoxy(24,13);scanf("%d",&num);system("cls");for(i=0; i<x; i++){if(electivedata[i].electivenum==num){if(screen>0){system("pause");system("cls");}cprintf("Here is the information you want:\n");cprintf("num:%d\n",electivedata[i].electivenum);cprintf("name:%s\n",electivedata[i].electivename);cprintf("kind:%s\n",electivedata[i].electivekind);cprintf("class:%d\n",electivedata[i].totalclassnum);cprintf("techclass:%d\n",electivedata[i].techclassnum);cprintf("expclass:%d\n",electivedata[i].expclassnum);cprintf("credits:%d\n",electivedata[i].credits);cprintf("term:%d\n",electivedata[i].classterm);cprintf("students:%d\n",electivedata[i].students);io=1;screen=screen+1;} }if(io==0){system("cls");cprintf("wrong number");gotoxy(1,24);system("pause");goto xx;}system("pause");goto xx;}b:screen=0;{system("cls");gotoxy(24,12);cprintf("Please write down the electivename\n");gotoxy(24,13); scanf("%s",&name);system("cls");for(i=0; i<x; i++){if(strcmp(electivedata[i].electivename,name)==0){if(screen>0){system("pause");system("cls");}cprintf("Here is the information you want:\n");cprintf("num:%d\n",electivedata[i].electivenum);cprintf("name:%s\n",electivedata[i].electivename);cprintf("kind:%s\n",electivedata[i].electivekind);cprintf("class:%d\n",electivedata[i].totalclassnum);cprintf("techclass:%d\n",electivedata[i].techclassnum);cprintf("expclass:%d\n",electivedata[i].expclassnum);cprintf("credits:%d\n",electivedata[i].credits);cprintf("term:%d\n",electivedata[i].classterm);cprintf("students:%d\n",electivedata[i].students);io=1;screen=screen+1;}}if(io==0){system("cls");cprintf("wrong number");gotoxy(1,24);system("pause");goto xx;}system("pause");goto xx;}c:screen=0;{system("cls");gotoxy(24,12);cprintf("Please write down the electivenkind\n");gotoxy(24,13); scanf("%s",&kind);system("cls");for(i=0; i<x; i++){if(strcmp(electivedata[i].electivekind,kind)==0){if(screen>0){system("pause");system("cls");}cprintf("Here is the information you want:\n");cprintf("num:%d\n",electivedata[i].electivenum);cprintf("name:%s\n",electivedata[i].electivename);cprintf("kind:%s\n",electivedata[i].electivekind);cprintf("class:%d\n",electivedata[i].totalclassnum);cprintf("techclass:%d\n",electivedata[i].techclassnum);cprintf("expclass:%d\n",electivedata[i].expclassnum);cprintf("credits:%d\n",electivedata[i].credits);cprintf("term:%d\n",electivedata[i].classterm);cprintf("students:%d\n",electivedata[i].students);io=1; screen=screen+1;} }if(io==0){system("cls");cprintf("wrong number");gotoxy(1,24);system("pause");goto xx;}system("pause");goto xx;}d:screen=0;{system("cls");gotoxy(24,12);cprintf("Please write down the totalclassnum\n");gotoxy(24,13); scanf("%d",&tonum);system("cls");for(i=0; i<x; i++){if(electivedata[i].totalclassnum==tonum){if(screen>0){system("pause");system("cls");}cprintf("Here is the information you want:\n");cprintf("num:%d\n",electivedata[i].electivenum);cprintf("name:%s\n",electivedata[i].electivename);cprintf("kind:%s\n",electivedata[i].electivekind);cprintf("class:%d\n",electivedata[i].totalclassnum);cprintf("techclass:%d\n",electivedata[i].techclassnum);cprintf("expclass:%d\n",electivedata[i].expclassnum);cprintf("credits:%d\n",electivedata[i].credits);cprintf("term:%d\n",electivedata[i].classterm);cprintf("students:%d\n",electivedata[i].students);io=1;screen=screen+1;} }if(io==0){system("cls");cprintf("wrong number");gotoxy(1,24);system("pause");goto xx;}system("pause");goto xx;}e:screen=0;{system("cls");gotoxy(24,12);cprintf("Please write down the techclassnum\n");gotoxy(24,13); scanf("%d",&tcnum);system("cls");for(i=0; i<x; i++){if(electivedata[i].techclassnum==tcnum){if(screen>0){system("pause");system("cls");}cprintf("Here is the information you want:\n");cprintf("num:%d\n",electivedata[i].electivenum);。
C语言课程设计报告 --学生管理系统一、实验目的:通过本次实验,学习C语言的语法和数据类型,设计一个简单的学生管理系统,结合文件I/O所学,可以将学生信息保存至文件中,再读取时自动填充至程序中。
同时,体验软件开发的流程,从需求分析到具体实现。
二、需求分析:1、学生信息包括:学号、姓名、性别、年龄、成绩。
2、学生信息需要添加、删除、修改、查找和显示。
3、程序启动时自动从文件中读取数据,退出时自动保存数据。
三、实验过程:1、确定数据结构和变量类型通过分析需求,学生信息包含多个属性,可以使用结构体来保存每个学生的信息。
同时,为了便于程序运行,需要定义一个链表来保存所有学生信息。
/* 学生信息结构体 */typedef struct _Student {char id[12]; // 学号char name[20]; // 姓名char gender; // 性别int age; // 年龄double score; // 成绩} Student;/* 学生信息链表节点 */typedef struct _StudentNode {Student data; // 学生信息struct _StudentNode *next; // 下一节点指针} StudentNode;/* 学生信息链表头节点 */StudentNode *head = NULL;2、设计主菜单功能考虑学生管理系统的主要功能,可以设计以下主菜单:---------------------------1. 添加学生2. 删除学生3. 修改学生信息4. 查找学生5. 显示所有学生6. 退出---------------------------可以使用一个while循环来循环处理,直到用户选择退出。
3、实现主菜单功能添加学生:先从用户输入中获取学生信息,然后创建一个新的学生信息节点,并将其添加到链表的末尾。
1. 定义变量/* 输入缓存区大小 */#define BUFFER_SIZE 2562. 实现函数/* 添加学生到链表末尾 */void add_student() {Student student; // 待添加的学生信息printf("请输入学号:");scanf("%s", student.id);printf("请输入姓名:");scanf("%s", );printf("请输入性别(M/F):");scanf(" %c", &student.gender);printf("请输入年龄:");scanf("%d", &student.age);printf("请输入成绩:");scanf("%lf", &student.score);StudentNode *node =(StudentNode*)malloc(sizeof(StudentNode));node->data = student;node->next = NULL;if (head == NULL) {head = node;} else {StudentNode *p = head;while (p->next != NULL) {p = p->next;}p->next = node;}printf("添加学生成功!\n");}删除学生:先从用户输入中获取学生学号,然后遍历链表,找到该学号对应的学生信息节点,并删除。
精心整理C语言程序设计报告1 课程设计题目:实验室设备管理里系统实验设备信息包括:设备编号、设备种类(如:微机打印机扫描仪等等)、设备名称、设备价格、设备购入日期、是否报废、报废日期等。
试设计一实验设备信息管理系统,使之能提供以下功能:(1)能够完成对设备的录入和修改(2)对设备进行分类统计(3)设备的查询2 需求分析实验室设备信息用文件存储,提供文件的输入输出操作;要能够完成设备的录入和修改,需要提供设备添加和修改操作;实现对设备进行分类统计,需要提供排序操作;实现对设备查询需要提供查找操作,设备的查询可根据设备编号设备种类设备购入日期正常设备(未报废的)等多种方式查询;另外还要根据键盘式选择菜单以实现功能选择。
3总体设计与模块的划分整个系统可设计为实验设备信息输入模块实验设备信息添加模块实验设备信息修改模块实验设备分类统计模块和实验设备查询模块。
主函数流程图:N+4 建立实验设备信息结构体 结构体成员包括设备编号 设备名称 部门编号 部门名称 设备价格 设备购买时间 是否报废 报废日期。
5应用程序功能详细说明程序运行后进入管理系统,显示目录:录入设备信息,修改设备信息,查询设备信息,统计设备信息,报废设备信息,退出录入设备信息 系统提示用户在原有的基础上录入新的设备信息。
流程图如下:录入设备信息修改设备信息查询设备信息统计设备信息报废设备信息退出设备管理系统设计开始 显示一系列功能选输入n,判断据n 值调用各功能模结束开始输入设备编号,并将(1)修改记录系统要求用户输入要修改的设备编号,这时系统会显示设备的具体信息,用户只需该设备新的信息按要求输入即可对信息进行修改。
流程图如下:开始判断是否有资料可以没有资料可以统计输入要统计的分类序按输入序号调用各功结束(2)显示记录无记录退出,有记录者按要求输出。
流程图如下:开(3) 统计分类 若有资料可以统计,则按要求分类统计输出。
流程图如下:(4) 查询记录 若信息为空,则不能查询。
课程设计报告课程名称C语言课程设计课题名称实验设设备管理系统专业计算机科学与技术班级191114班学号20111001948姓名吕浙明指导教师2010年08 月27日中国地质大学计算机高级语言(C)课程设计报告姓名吕浙明学号20111001948班级191114专业计算机科学与技术指导教师刘文中2012年1月15 日目录1、系统程序需求分析2、系统程序总体设计与模块划分3、系统程序详细设计与程序调试4、实习总结和心得体会C语言程序设计报告--实验设备信息管理系统一课程设计的目的提高程序设计能力,检验课堂教学内容,掌握程序设计的基本方法和调试技能。
二课程设计报告正文课程设计题目实验设备信息包括:设备编号、设备种类(如:微机打印机扫描仪等等)、设备名称、设备价格、设备购入日期、是否报废、报废日期等。
试设计一实验设备信息管理系统,使之能提供以下功能:(1)能够完成对设备的录入和修改(2)对设备进行分类统计(3)设备的查询1 需求分析实验室设备信息用文件存储,提供文件的输入输出操作;要能够完成设备的录入和修改,需要提供设备添加和修改操作;实现对设备进行分类统计,需要提供排序操作;实现对设备查询需要提供查找操作,设备的查询可根据设备编号设备种类设备购入日期正常设备(未报废的)等多种方式查询;另外还要根据键盘式选择菜单以实现功能选择。
2总体设计与模块的划分整个系统可设计为实验设备信息输入模块实验设备信息添加模块实验设备信息修改模块实验设备分类统计模块和实验设备查询模块。
4 建立实验设备信息结构体,结构体成员包括设备编号设备种类设备名称设备价格设备购入日期是否报废报废日期。
3 详细设计3.1流程图显示3.2 程序源代码A (1)各种各样的头文件以及各样的函数定义#include<stdio.h>#include<stdlib.h>#include<string.h>#define N 50void menu();void add();void modify(); //修改void stat(); //统计void search();int load();(2)主函数主函数是整个程序的核心。
它将其他函数包含在其中,是整个程序的“大脑”,它调用很多函数,为了是读者更加的清晰,明白,在主函数中又调用了其他的函数。
void menu(){ int n;puts("\t\t\t\t 1.添加您所需实验设备的信息");puts("\t\t\t\t 2.修改您所需实验设备的信息");puts("\t\t\t\t 3.统计您所需实验设备的信息");puts("\t\t\t\t 4.查询您所需实验设备的信息");puts("\t\t\t\t 5.退出");printf("清选择你所需服务的号码(1-5): [ ]\b\b");scanf("%d",&n);switch(n){case 1:add();break;case 2:modify();break;case 3:stat();break;case 4:search();break;case 5:exit(0);default:menu();}}void main() /*主函数*/{menu();getchar();}B 各功能模块设计(1)添加实验设备信息模块void add(){int i;FILE *fp;fp=fopen("eup.txt","a");if((fp=fopen("eup.txt","a"))==NULL){printf("cannot open file\n");}printf("\n 输入:编号\t 种类\t 名称\t 价格\t购入日期\t是否报废\t 报废日期\n");scanf("%s",temp.id);scanf("%s",temp.kind);scanf("%s",);scanf("%s",temp.price);scanf("%s",temp.in_date);scanf("%s",temp.reject);scanf("%s",temp.out_date);fprintf(fp,"\n %s \t %s \t%s \t %s \t %s \t %s \t %s",temp.id,temp.kind,,temp.price,temp.in_date,temp.reject,temp.out_date);fclose(fp);printf("\n\n\t Successful.^_^ \n\n");printf("\n*********************************************************\n");printf("What do you want to do?\n\n");printf("\t 1.继续添加\t 2.返回主菜单\t 3.退出\n");printf("\n************************************************************\n");printf("\n\n 输入你要选择的号码(1-3):");scanf("%d",&i);if(i==1){add();}if(i==2){menu();}if(i==3){}}(3)修改模块先判断是否能找到要修改的信息,如果找不到用户要修改实验设备信息的编号,则提醒用户“对不起,没有你所需的文件信息!”,若能找到用户要修改的信息的编号,则依次输出要修改的项目提示进行逐项修改,完成各项修改后输出提示:“1.继续修改\t 2.返回主菜单\t 3.退出”void modify(){FILE *fp;int n,k=0,b,c,i,e;char a[10];n=load();for(i=0;i<n;i++){printf("%s \t %s \t %s \t %s \t %s \t %s \t %s \n",eup[i].id,eup[i].kind,eup[i].name,eup[i].price,eup[i].in_date,eup[i].reject,eup[i].out_date);}printf("\n 输入你要修改的设备的编号! \n\n 实验设备的编号:");scanf("%s",a);for(i=0;i<n;i++) if(strcmp(a,eup[i].id)==0) /*查找要修改的设备信息*/ {k=1;c=i;break;if(k==0){printf("\n\n 对不起,没有你所需的文件信息!");printf("\t1).文件内容在这里2).返回主菜单[]\b\b");scanf("%d",&b);if(b==1){modify();}if(b==2){menu();}}if(k==1){printf("\n 找到要修改的设备! \n");printf("\n 请输入你要修改的新信息:\n");printf("\n 编号种类名称价格购入日期是否报废报废日期\n");scanf("%s",eup[c].id);scanf("%s",eup[c].kind);scanf("%s",eup[c].name);scanf("%s",eup[c].price);scanf("%s",eup[c].in_date);scanf("%s",eup[c].reject);scanf("%s",eup[c].out_date);}fp=fopen("eup.txt","w");}统for(i=0;i<n;i++){fprintf(fp,"%s \t %s \t %s \t %s \t %s \t %s \t %s \n",eup[i].id,eup[i].kind,eup[i].name,eup[i].price,eup[i].in_date,eup[i].reject,eup[i].out_date);}fclose(fp);printf("\n\n\t Successful.^_^ \n\n");printf("\n********************************************************************\n");printf(" 你还想做什么?\n\n");printf("\t 1.继续修改\t 2.返回主菜单\t 3.退出\n");printf("\n*********************************************************************\n");printf("\n\n 你的选择(1-3):");scanf("%d",&e);if(e==1){modify();}if(e==2){menu();}if(e==3){exit(0);}}(4)统计模块void stat(){FILE *fp;fp=fopen("eup.txt","r");if((fp=fopen("eup.txt","r"))==NULL){printf("cannot open file\n");}while(!feof(fp)){fscanf(fp,"\n%s %s %s %s %s %s %s",temp.id,temp.kind,,temp.price,te mp.in_date,temp.reject,temp.out_date);printf("\n%s\t%s\t%s\t%s\t%s\t%s\t%s",temp.id,temp.kind,,temp.price,te mp.in_date,temp.reject,temp.out_date);}fclose(fp);menu();}(5)查询模块void search(){int i,n,k=-1,w1,w2,w3;char c[10];n=load();printf("\n \n 按照具体条件进行查找: \n \n 1).实验设备的编号2).种类3).名称4).购入日期[ ]\b\b");scanf("%d",&w3);switch(w3){case 1:{printf("\n\n 请输入要查找的设备的编号! 设备的编号:");scanf("%s",c);for(i=0;i<n;i++)if(strcmp(c,eup[i].id)==0){k=i;printf("\n已经找到实验的设备!\n");printf("\n该设备的实验信息:\n");printf("\n 编号种类名称价格购入日期是否报废报废日期\n \n");printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\n",eup[i].id,eup[i].kind,eup[i].name,eup[i].price,eup[i]. in_date,eup[i].reject,eup[i].out_date);}if (k!=-1)printf("\n\n Successful.^_^.");if (k==-1)printf(" 不能找到该设备的信息!\n");printf("\n\t 1).重新查找2).返回主菜单[ ]\b\b");scanf("%d",&w2);if(w2==2) menu();if(w2==1) search();}break;case 2:{printf("\n\n输入要查找的实验的设备的种类! 设备的种类:");scanf("%s",c);for(i=0;i<n;i++)if(strcmp(c,eup[i].kind)==0){k=i;printf("\n 能找到该设备哦! \n");printf("\n该设备的信息:\n");printf("\n编号种类名称价格购入日期是否报废报废日期\n\n");printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\n",eup[i].id,eup[i].kind,eup[i].name,eup[i].price,eup[i]. in_date,eup[i].reject,eup[i].out_date);}if (k!=-1)printf("\n\n Successful.^_^.");if (k==-1)printf("不能找到该设备!\n");printf("\n\t1).重新查找2).返回主菜单[ ]\b\b");scanf("%d",&w2);if(w2==2) menu();if(w2==1) search();}break;case 3:{printf("\n\n输入要查找的设备的名称! 名称:");scanf("%s",c);for(i=0;i<n;i++)if(strcmp(c,eup[i].name)==0){k=i;printf("\n已经找到该设备!\n");printf("\n设备的信息:\n");printf("\n编号种类名称价格购入日期是否报废报废日期\n\n");printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\n",eup[i].id,eup[i].kind,eup[i].name,eup[i].price,eup[i]. in_date,eup[i].reject,eup[i].out_date);}if (k!=-1)printf("\n\n Successful.^_^.");if (k==-1)printf("不能找到该设备的信息");printf("\n\t1).再次查找2).返回主菜单[ ]\b\b");scanf("%d",&w2);if(w2==2) menu();if(w2==1) search();}break;case 4:{printf("\n\n输入要查找的实验设备的购入的日期! 购入的日期:");scanf("%s",c);for(i=0;i<n;i++)if(strcmp(c,eup[i].in_date)==0){k=i;printf("\n已经能够找到该设备!\n");printf("\n该设备的信息:\n");printf("\n编号种类名称价格购入日期是否报废报废日期\n\n");printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\n",eup[i].id,eup[i].kind,eup[i].name,eup[i].price,eup[i]. in_date,eup[i].reject,eup[i].out_date);}if (k!=-1)printf("\n\nSuccessful.^_^.");if (k==-1)printf("不能找到该设备!\n");printf("\n\t1).再次查找2).返回主菜单[ ]\b\b");scanf("%d",&w2);if(w2==2) menu();if(w2==1) search();}}}5、总结与体会这一次课程设计着实考研了我们对C语言知识的掌握情况。