C语言程序设计-机房管理系统

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

#includestdio.h#includestring.h#defineSize100structmachine{intbianhao;charzhuban[10];charyingpan[10];charneicun[10];charzhupin[10];charxianka[10];charfangjian[10];charshiyong[10];}Com[Size];voidmenu();voidpassword();voidinsert(int*);voidsearch1(int);//voidsearch2(int);voidupdate(int);voidDelete(int*);voidshow(int);voidsave();voidread();intcount=0;intmain(){inti;charname[20];charad[20]={zyc};password();{read();do{menu();scanf(%d,&i);switch(i){case1:insert(&count);break;case2:search1(count);break;case3:update(count);break;case4:Delete(&count);break;case5:show(count);break;case6:save();break;default:printf(errow!);break;}}while(i!=6);}if(strcmp(ad,name)!=0)//printf(Youarewrong!\n);return0;}voidpassword(){inti;charname[20];charad[20]={zyc};printf(请输入验证信息:);scanf(%s,name);if(strcmp(ad,name)==0);}voidmenu(){printf(\n);printf(---------------北软机房管理系统---------------\n);printf(---1.插入---\n);printf(---2.按编号查找---\n);//printf(---3.按机房查找---\n);printf(---3.修改---\n);printf(---4.删除---\n);printf(---5.显示---\n);printf(---6.退出---\n);}voidinsert(int*count){inti,number;if(*count==Size){printf(full!);return;}printf(请输入编号:);scanf(%d,&number);for(i=0;i*count;i++)if(Com[i].bianhao==number){printf(已经有相同的编号:);return;}Com[i].bianhao=number;printf(请输入主板型号:);scanf(%s,Com[i].zhuban);printf(请输入硬盘容量:);scanf(%s,Com[i].yingpan);printf(请输入内存容量:);scanf(%s,Com[i].neicun);printf(请输入cpu主频:);scanf(%s,Com[i].zhupin);printf(请输入显卡型号:);scanf(%s,Com[i].xianka);printf(请输入机器所属机房:);scanf(%s,Com[i].fangjian);printf(请输入机器使用情况:);scanf(%s,Com[i].shiyong);(*count)++;}voidsearch1(intcount){inti,number,flag=0;printf(请输入要查询的编号:);scanf(%d,&number);for(i=0;icount;i++)if(Com[i].bianhao==number){printf(机器编号:%d\n,Com[i].bianhao);printf(主板型号:%s\n,Com[i].zhuban);printf(硬盘容量:%s\n,Com[i].yingpan);printf(内存容量:%s\n,Com[i].neicun);printf(机器主频:%s\n,Com[i].zhupin);printf(显卡型号:%s\n,Com[i].xianka);printf(所属机房:%s\n,Com[i].fangjian);printf(使用情况:%s\n,Com[i].shiyong);flag=1;}if(flag==0)printf(没有查到!);}/*voidsearch2(intcount){inti,flag=0;intnumber;printf(请输入要查询的主板:);scanf(%d,&number);for(i=0;icount;i++)if(Com[i].fangjian==number){printf(机器编号:%d\n,Com[i].bianhao);printf(主板型号:%s\n,Com[i].zhuban);printf(硬盘容量:%s\n,Com[i].yingpan);printf(内存容量:%s\n,Com[i].neicun);printf(机器主频:%s\n,Com[i].zhupin);printf(显卡型号:%s\n,Com[i].xianka);printf(所属机房:%d\n,Com[i].fangjian);printf(使用情况:%s\n,Com[i].shiyong);flag=1;}if(flag==0)printf(没有查到!);}*/voidupdate(intcount){inti,number,flag=0;printf(请输入要修改的编号:);scanf(%d,&number);for(i=0;icount;i++)if(Com[i].bianhao==number){printf(请输入主板型号:);scanf(%s,Com[i].zhuban);printf(请输入硬盘容量:);scanf(%s,Com[i].yingpan);printf(请输入内存容量:);scanf(%s,Com[i].neicun);printf(请输入cpu主频:);scanf(%s,Com[i].zhupin);printf(请输入显卡型号:);scanf(%s,Com[i].xianka);printf(请输入机器所属机房:);scanf(%s,Com[i].fangjian);printf(请输入机器使用情况:);scanf(%s,Com[i].shiyong);flag=1;}if(flag==0)printf(没有查到可以修改的数据!);}voidDelete(int*count){inti,j,number,flag=0;printf(请输入要删除的编号:);scanf(%d,&number);for(i=0;i*count;i++){if(Com[i].bianhao==number){for(j=i;j*count-1;j++)Com[j]=Com[j+1];(*count)--;flag=1;}}if(flag==0)printf(没有查询到可删除的数据:);}voidshow(intcount){inti;printf(\n);printf(编号主板硬盘内存主频显卡机房使用\n);for(i=0;icount;i++){printf(%8d,Com[i].bianhao);printf(%8s,Com[i].zhuban);printf(%8s,Com[i].yingpan);printf(%8s,Com[i].neicun);printf(%8s,Com[i].zhupin);printf(%8s,Com[i].xianka);printf(%8s,Com[i].fangjian);printf(%8s,Com[i].shiyong);printf(\n);}printf(机器总数量:%d,i);}voidsave(){FILE*fp;inti;if((fp=fopen(D:\\jiqi.txt,wb))==NULL){printf(cannotopenfile\n);return;}for(i=0;icount;i++)if(fwrite(&Com[i],sizeof(structmachine),1,fp)!=1)printf(filewriteerror!);fclose(fp);}voidread(){FILE*fp;inti=0;if((fp=fopen(D:\\jiqi.txt,rb))==NULL){return;}while(!feof(fp))if(fread(&Com[i],sizeof(structmachine),1,fp)==1){count++;i++;}fclose(fp);}

1 / 8
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功