C语言宿舍管理系统源程序

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

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

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

资源描述

/*Ō´³ĢŠņѧɜĖŽÉį¹ÜĄķĻµĶ³(domitry.txt)*//*³ĢŠņÖŠÓƵ½µÄĶ·Īļž*/#includestdio.h#includestring.h#includestdlib.h#includeconio.h#defineMAX100/*Źż×éŌŖĖŲµÄøöŹż*/#definePRINT1printf(\n);#definePRINT2printf(ѧŗÅ----ѧɜŠÕĆū-ŠŌ±š-ÄźĮä--Äź¼¶--°ą¼¶--×ØŅµ-------·æ¼äŗÅ--´²ŗÅ\n\n);intsum;/*¶ØŅå½į¹¹ĢåŹż×é*/structstu{charname[20];/*ŠÕĆū*/intnum;/*ѧŗÅ*/charsex;/*ŠŌ±š*/intage;/*ÄźĮä*/intgrade;/*Äź¼¶*/intbanji;/*°ą¼¶*/charzhuanye[30];/*×ØŅµ*/};structdomintroom_num;/*·æ¼äŗÅ*/intbed_num;/*´²ŗÅ*/structstust;}s[MAX],p;/*ĆÜĀėÄ£æé*/intlogin_message(){charmima[]=123456;charstr[10]={0},ch;inti=0,n=strlen(mima),num=0,flag=0;do{printf(ĒėŹäČėĆÜĀė(ÄćÖ»ÓŠČż´Ī»ś»į)£ŗ\n);for(i=0;in;i++){ch=getch();if(ch!='\n'){putchar('*');str[i]=ch;}}getchar();if(strcmp(str,mima)==0){printf(ĆÜĀėÕżČ·\n);flag=1;}else{printf(ĆÜĀė´ķĪó£¬ĒėÖŲŠĀŹäČė:\n);num++;}}while(flag==0&&num3);returnflag;}/*ŗÆŹżÉłĆ÷*/voidsave_message();intinput_message();intread_message();voidoutput_message();intinsert_message();intdel_message();intrevise_message();intrenew_message();intinquire_message();intcount_message();intsort_num();intsort_conidition();intsort_message();/*±£´ęŠÅĻ¢*/voidsave_message(intsum){FILE*fp;inti;if((fp=fopen(dom.txt,wt))==NULL){printf(Īļž´ņæŖŹ§°Ü!\n);exit(1);}for(i=0;isum;i++){printf(ѧŗÅ----ѧɜŠÕĆū-ŠŌ±š-ÄźĮä--Äź¼¶--°ą¼¶--×ØŅµ----ŗÅ---·æ¼äŗÅ--´²ŗÅ);fprintf(fp,\n%2d%10s%6c%7d%6d%5d%8s%5d%6d%8d%9d,s[i].st.num,s[i].st.name,s[i].st.sex,s[i].st.age,s[i].st.grade,s[i].st.banji,s[i].st.zhuanye,s[i].bui_num,s[i].floor_num,s[i].room_num,s[i].bed_num);printf(\n);}fclose(fp);}/*ŹäČėÄ£æé*/intinput_message(){inti=0;system(cls);printf(\n\nĀ¼ČėѧɜŠÅĻ¢(×ī¶ą%døö)\n,MAX);printf(______________________\n);do{printf(\nµŚ%døöѧɜ\n\n,i+1);printf(\nѧŗÅ£ŗ);scanf(%d,&s[i].st.num);if(s[i].st.num==0)break;printf(\nѧɜŠÕĆū£ŗ);scanf(%s,s[i].st.name);printf(\nѧɜŠŌ±š(ÄŠÉśÓĆM±ķŹ¾£¬Å®ÉśÓĆF±ķŹ¾)£ŗ);getchar();scanf(%c,&s[i].st.sex);printf(\nѧɜğĮä:);scanf(%d,&s[i].st.age);printf(\nѧɜğ¼¶:);scanf(%d,&s[i].st.grade);printf(\nѧɜ°ą¼¶:);scanf(%d,&s[i].st.banji);printf(\nѧɜ×ØŅµ:);scanf(%s,&s[i].st.zhuanye);printf(\scanf(%d,&s[i].bui_num);printf(\scanf(%d,&s[i].floor_num);printf(\nĖŽÉį·æ¼äŗÅ:);scanf(%d,&s[i].room_num);printf(\nĖŽÉį´²ŗÅ:);scanf(%d,&s[i].bed_num);i++;}while(iMAX);printf(\n---%døöѧɜµÄŠÅĻ¢ŹäČėĶź±Ļ---\n,i);sum=i;printf(\getchar();getch();returnsum;}intread_message(){FILE*fp;inti=0,sum;if((fp=fopen(dom.txt,rt))==NULL){printf(Īļž´ņæŖŹ§°Ü!\n);exit(1);}while(!feof(fp))for(i=0;isum;i++){fscanf(fp,%d%s%c%d%d%d%s%d%d%d%d,&s[i].st.num,s[i].st.name,&s[i].st.sex,&s[i].st.age,&s[i].st.grade,&s[i].st.banji,s[i].st.zhuanye,&s[i].bui_num,&s[i].floor_num,&s[i].room_num,&s[i].bed_num);}fclose(fp);returni=0;for(i=0;isum;i++){printf(%2d%10s%6c%7d%6d%5d%8s%5d%6d%8d%9d,s[i].st.num,s[i].st.name,s[i].st.sex,s[i].st.age,s[i].st.grade,s[i].st.banji,s[i].st.zhuanye,s[i].bui_num,s[i].floor_num,s[i].room_num,s[i].bed_num);}}*//*Źä³öÄ£æé*/voidoutput_message(){inti=0;system(cls);printf(\n\n---ѧɜŠÅĻ¢ĮŠ±ķ---\n\n);PRINT1;PRINT2;for(i=0;isum;i++)if(s[i].st.num!=0){printf(\n%2d%10s%6c%7d%6d%5d%8s%5d%6d%8d%9d\n\n,s[i].st.num,s[i].st.name,s[i].st.sex,s[i].st.age,s[i].st.grade,s[i].st.banji,s[i].st.zhuanye,s[i].bui_num,s[i].floor_num,s[i].room_num,s[i].bed_num);getch();}}/*Ģķ¼ÓѧɜŠÅĻ¢*/intinsert_message(){inti=sum,flag=0;charchoice;system(cls);printf(\n\nĢķ¼ÓŅ»øöŠĀĶ¬Ń§\n);printf(______________\n);do{printf(\nŠĀѧŗÅ:);scanf(%d,&s[i].st.num);printf(\nѧɜŠÕĆū£ŗ);scanf(%s,s[i].st.name);printf(\nѧɜŠŌ±š(ÄŠÉśÓĆM±ķŹ¾£¬Å®ÉśÓĆF±ķŹ¾)£ŗ);getchar();scanf(%c,&s[i].st.sex);printf(\nѧɜğĮä:);scanf(%d,&s[i].st.age);printf(\nѧɜğ¼¶:);scanf(%d,&s[i].st.grade);printf(\nѧɜ°ą¼¶:);scanf(%d,&s[i].st.banji);printf(\nѧɜ×ØŅµ:);scanf(%s,&s[i].st.zhuanye);printf(\scanf(%d,&s[i].bui_num);printf(\;scanf(%d,&s[i].floor_num);printf(\nĖŽÉį·æ¼äŗÅ:);scanf(%d,&s[i].room_num);printf(\nĖŽÉį´²ŗÅ:);scanf(%d,&s[i].bed_num);sum++;printf(\nŅŖ¼ĢŠųĀš(Y/N));getchar();scanf(%c,&choice);if(choice=='Y'||choice=='y'){flag=1;i++;printf(\n¼ĢŠų!\n);}elseflag=0;}while(flag==1);printf(\return0;}/*ɾ³żÄ£æé*/intdel_message(){intflg,del_num,i,k,flag=0;charchoice;do{system(cls);printf(\nŹäČėŅŖɾ³żµÄѧɜѧŗÅ:);scanf(%d,&del_num);for(i=0;flag==0&&isum;i++)if(del_num==s[i].st.num){for(k=i;ksum-1;k++)s[k]=s[k+1];flag=1;sum--;break;}if(flag==1)printf(ɾ³ż³É¹¦!\n);printf(°´ČĪŅā¼ü¼ĢŠų...\n);getch();printf(\n\n¼ĢŠųĀš?(Y/N));getchar();scanf(%c,&choice);if(choice=='Y'||choice=='y'){flg=1;printf(\n¼ĢŠų!\n);}elseflg=0;}while(flg==1);printf(\getchar();return0;}/*ŠŽøÄÄ£æé*/intrevise_message(){inti=0,choices,revise_num,flag=0;charname[20];intnum;charsex;intage;intgrade;intbanji;charzhuanye[30];intbui_num;intfloor_num;introom_num;intbed_num;//intsum=read_message();intsum=MAX;do{system(cls);printf(\nŹäČėŅŖŠŽøĵÄѧɜŗÅ£ŗ);scanf(%d,&revise_num);for(i=0;isum;i++)if(i==revise_num){printf(\n----ѧɜŠÅĻ¢----\n);PRINT1;PRINT2;printf(%2d%s%6c%7d%6d%5d%8s%5d%6d%8d%9d\n\n,s[i].st.num,s[i].st.name,s[i].st.sex,s[i].st.age,s[i].st.grade,s[i].st.banji,s[i].st.zhuanye,s[i].bui_

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

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

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

×
保存成功