commit ed6726ac9bbc8146a800c55110dd5a44d0a04600 Author: 1003039891@qq.com <1003039891@qq.com> Date: Mon Jan 14 17:23:18 2019 +0800 first diff --git a/文件删除.c b/文件删除.c new file mode 100644 index 0000000..9da870a --- /dev/null +++ b/文件删除.c @@ -0,0 +1,220 @@ +#include"stdio.h" +#include +#include"stdlib.h" +#include"string.h" +#define T (time-8)/2 +int sum[6]={0}; +int computer[6][20]={{1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1}, +{1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1}, + {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, + {1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,0,0,1,1,1}, + {1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,0,0,1,1,1}, + {1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1}}; + int menu(); + int cx(); + int yd(); + int qxyd(); + int searchwaiting(); + int detail(int time); + + struct waitlist + { + char shijian[2]; + char number[3]; + char telephonenumber[11]; + }wait[20]; + + int main() + { + printf("ÇëÊäÈëÃÜÂë!\n"); + char MIMA[11]="123456"; + char mima[11]; + scanf("%s",mima); + if(strcmp(mima,MIMA)==0) + {menu();} + } + + int menu() + { + int n,w; + do{ + printf("\t\t***************»ú·¿»úλԤ¶¨ÏµÍ³***************\n"); + printf("\t\t ******************²Ëµ¥******************\n"); + printf("\n\n\n"); + printf("\t\t\t 1.²éѯij¶Îʱ¼ä»úλ״̬\n"); + printf("\t\t\t 2.Ô¤¶¨¿Õ»úλ\n"); + printf("\t\t\t 3.È¡ÏûÔ¤¶¨\n"); + printf("\t\t\t 4.²éѯµÈ´ýÐÅÏ¢\n"); + printf("\t\t\t 5.Í˳ö\n"); + printf("ÇëÊäÈëÖ¸Áî(1-5):"); + scanf("%d",&n); + if(n<1||n>5) + w=1; + else + w=0; + }while(w==1); + switch(n) + { + case 1:cx(); break; + case 2:yd(); break; + case 3:qxyd();break; + case 4:searchwaiting();break; + case 5:exit(0);break; + } + } + int cx() + { + system("cls"); + int time; + printf("ÊäÈëʱ¼ä(8-19):"); + scanf("%d",&time); + if(time<8||time>20) + { + printf("\tʱ¼äÊäÈë´íÎó\n"); + printf("ÊäÈëÔÚ£¨8-19£©·¶Î§ÄÚµÄʱ¼ä£º"); + scanf("%d",&time); + } + detail(time); + menu(); + } + int yd() + { + system("cls"); + int time,i=0,x,y; + FILE *fp; + char c; + printf("ÔÚ£¨8-19£©Ê±¼äÄÚÊäÈëÄãÏëÒªµÄÔ¤¶¨Ê±¼ä£º"); + scanf("%d",&time); + if(time<8||time>20) + { + printf("ʱ¼äÊäÈë´íÎó£¡\n"); + printf("ÔÚ£¨8-19£©Ê±¼äÄÚÊäÈëÄãÏëÒªµÄÔ¤¶¨Ê±¼ä£º"); + scanf("%d",&time); + } + detail(time); + if(sum[T]>0) + { + if((fp=fopen("waitlist.txt","a"))==NULL) + { + printf("\nÎÞ·¨´ò¿ªÎļþ£¡\n"); + exit(0); + } + printf("ÇëÊäÈëÄãÏëÒªÔ¤¶¨µÄʱ¼ä£¬»úºÅ²¢ÁôÏÂÄãµÄµç»°ºÅÂë!:"); + scanf("%s %s %s",wait[i].shijian,wait[i].number,wait[i].telephonenumber); + fprintf(fp,"%s %s %s\n",wait[i].shijian,wait[i].number,wait[i].telephonenumber); + fclose(fp); + printf("ÔÙ´ÎÊäÈëÄãÏëÒªÔ¤¶¨µÄ»úºÅ!\n"); + scanf("%d",&x); + sum[T]--; + computer[T][x]=1; + printf("\nÔ¤¶¨³É¹¦\n"); + menu(); + } + else + { + printf("ÕâÊÇÔÚ×î½üʱ¼ä¶ÎÄÚδԤ¶¨µÄµçÄÔ!\n"); + for(i=T+1;i<6;i++) + { + time=9+2*i; + detail(time); + if(sum[T]>0) + printf("×î½üµÄ¿ÕÏÐʱ¼ä¶ÎÊÇ%d-%d\n",2*i+8,2*i+10);break; + } + printf("ÄãÏëÒªÔ¤¶¨Âð?:y/n?:"); + scanf("%s",&c); + if(c=='Y'||c=='y') + { + printf("ÇëÊäÈëÄúÏëÔ¤¶¨µÄʱ¼ä£¬»úºÅ²¢ÁôÏÂÄúµÄÁªÏµ·½Ê½!:\n"); + if((fp=fopen("waitlist.txt","a"))==NULL) + { + printf("\nÎÞ·¨´ò¿ªÎļþ!\n"); + exit(0); + } + scanf("%s %s %s",wait[i].shijian,wait[i].number,wait[i].telephonenumber); + fwrite(&wait[i],sizeof(struct waitlist),1,fp); + fclose(fp); + printf("ÔÙ´ÎÊäÈëµçÄÔµÄÐòºÅ!\n"); + scanf("%d",&y); + sum[T]--; + computer[T][y]=1; + printf("Ô¤¶¨³É¹¦!\n"); + menu(); + } + else menu(); + } + } + int qxyd() + { + system("cls"); + int time,number; + printf("ÔÚ(8-20)ʱ¼äÄÚÊäÈëÄãÒѾ­Ô¤¶¨µÄʱ¼ä:"); + scanf("%d",&time); + if(time<8||time>20) + { + printf("ÊäÈëʱ¼ä´íÎó!\n"); + printf("ÔÚ(8-20)ʱ¼ä·¶Î§ÄÚÊäÈëÄãÒѾ­Ô¤¶¨µÄʱ¼ä:"); + scanf("%d",&time); + } + printf("ÊäÈëÄãÔ¤¶¨µÄʱ¼äºÍ»úºÅ:"); + printf("ÔÙ´ÎÊäÈëÔ¤¶¨µÄ»úºÅ!"); + scanf("%d",&number); + sum[T]++; + computer[T][number]=0; + printf("È¡Ïû³É¹¦!\n"); + menu(); + } + int searchwaiting() + { + int time,i; + FILE *fp; + printf("ÔÚ(8-20)Ö®¼äÊäÈëÄúÏëÒªËÑË÷µÄʱ¼ä:"); + scanf("%d",&time); + if(time<8||time>20) + { + printf("ʱ¼äÊäÈë´íÎó!\n"); + printf("ÔÚ(8-20)Ö®¼äÊäÈëÄúÒªËÑË÷µÄʱ¼ä:"); + scanf("%d",&time); + } + + + else if((fp=fopen("waitlist.txt","r"))==NULL) + { + printf("\nÎÞ·¨´ò¿ªÎļþ!\n"); + exit(0); + } + else + { + printf("waitlist:shijian number telephonenumber\n"); + for(i=0;!feof(fp);i++) + { + fscanf(fp,"%s %s %s",&wait[i].shijian,&wait[i].number,&wait[i].telephonenumber); + } + fclose(fp); + } + for(i=0;i<10;i++) + { + printf("\t %s %s %s\n",wait[i].shijian,wait[i].number,wait[i].telephonenumber); + } + menu(); + } +int detail(int time) +{ + int i,s=0,j=0; + int v[20]; + for( i=0;i<20;i++) + { + if(computer[T][i]==0) + { + s=s+1; + v[j]=i; + j++; + } + } + sum[T]=s; + printf("¿ÕÖõĵçÄÔÊýΪ%d\n",sum[T]); + printf("¿ÕÖõĵçÄÔÊÇ£º\n"); + for( i=0;i