diff --git a/C语言课程设计.c b/C语言课程设计.c index acaec61..dbfa56d 100644 --- a/C语言课程设计.c +++ b/C语言课程设计.c @@ -30,16 +30,16 @@ Menu(); /* } void Menu() /*Ö÷½çÃæ*/ { -int n,w; + int n,w; do { puts("\t\t****************»ú·¿»úλԤԼϵͳ*********************\n"); -puts("\t\t*********************²Ëµ¥****************************\n"); +puts("\t\t********************²Ëµ¥*****************************\n"); puts("\t\t\t |1.²éѯijʱ¼ä¶Î»úλ״̬|"); /*²éѯijʱ¼ä¶Î»úλ״̬*/ puts("\t\t\t |2.Ô¤¶¨¿Õ»úλ\t\t|"); /*Ô¤¶¨¿Õ»úλ*/ -puts("\t\t\t |3.È¡ÏûÔ¤¶©\t\t|"); /*È¡ÏûÔ¤¶©*/ -puts("\t\t\t |4.²éѯµÈ´ýÐÅÏ¢\t|"); /*²éѯµÈ´ýÐÅÏ¢*/ -puts("\t\t\t |5.Í˳ö\t\t|\n"); /*Í˳ö*/ +puts("\t\t\t |3.È¡ÏûÔ¤¶© \t\t|"); /*È¡ÏûÔ¤¶©*/ +puts("\t\t\t |4.²éѯµÈ´ýÐÅÏ¢ \t|"); /*²éѯµÈ´ýÐÅÏ¢*/ +puts("\t\t\t |5.Í˳ö \t\t|\n"); /*Í˳ö*/ puts("\t\t*****************************************************\n"); printf("Ñ¡Ôñ²Ëµ¥ºÅ(1-5):"); scanf("%d",&n); @@ -69,7 +69,7 @@ if(time<8||time>20) printf("ÇëÊäÈëÔÚ (8-20)·¶Î§ÄÚµÄʱ¼ä:"); scanf("%d",&time); } -detail(time); /*µ÷ÓÃdetailº¯Êý*/ +detail(time); /*µ÷ÓÃdetailº¯Êý£¬Êä³ö¿ÕÖûúλ*/ getchar(); Menu(); } @@ -95,11 +95,11 @@ if(sum[T]>0) /* exit(0); } printf("\n\tÇëÊäÈëÄãÏëÒªÔ¤¶¨µÄ»úºÅ£¬²¢ÇÒÁôÏÂÄãµÄµç»°ºÅÂë:\n"); - scanf("%s %s",wait[i].number,wait[i].telephonenumber); + scanf("%s %s",wait[i].number,wait[i].telephonenumber); /*¼ÈëÔ¤¶¨ÐÅÏ¢*/ //for(i=0;i<1;i++) fwrite(&wait[i],sizeof(struct waitlist),1,fp); /*ÏòÎı¾ÎĵµÌí¼ÓÒ»¸ö½á¹¹Ìåµ¥Ôª*/ fclose(fp); /*¹Ø±ÕÎļþ*/ - printf("ÔÙ´ÎÊäÈëµçÄÔµÄÐòºÅ!\n"); + printf("ÇëÔÙ´ÎÊäÈëÔ¤¶¨µçÄԵĻúºÅ!\n"); scanf("%d",&x); sum[T]--; /*Ô¤¶¨ºó¸Ãʱ¼ä¶Î¿Õ»úλÊý¼õ1*/ computer[T][x]=0; /*Ô¤¶¨ºó¸Ã»ú״̬±äΪ0*/ @@ -138,18 +138,18 @@ else /* fclose(fp); } for(i=0;i<10;i++) - { prione(i);} + { prione(i);} /*Êä³ö¸÷ʱ¼ä¶ÎµÄµÈ´ýÁбí*/ printf("\n\tÇëÊäÈëÄúÏëÔ¤¶¨µÄ»úºÅ£¬²¢ÁôÏÂÄúµÄÁªÏµ·½Ê½:\n"); if((fp=fopen("waitlist.txt","a"))==NULL) { printf("\nÎÞ·¨´ò¿ªÎļþ!\n"); exit(0); } - scanf("%s %s",wait[i].number,wait[i].telephonenumber); + scanf("%s %s",wait[i].number,wait[i].telephonenumber); /*¼ÈëÔ¤¶¨ÐÅÏ¢*/ for(i=0;i<1;i++) fwrite(&wait[i],sizeof(struct waitlist),1,fp); - fclose(fp); /*ÈôµÈ´ý£¬¾ÍÓÃÎļþµÄ·½Ê½Áгöµ±Ê±µÄµÈ´ýÁÐ±í²¢ÌáʾÊäÈëµÈ´ýÐòºÅºÍÁªÏµ·½Ê½*/ - printf("ÔÙ´ÎÊäÈëµçÄÔµÄÐòºÅ!\n"); + fclose(fp); + printf("ÇëÔÙ´ÎÊäÈëÔ¤¶¨µçÄԵĻúºÅ!\n"); scanf("%d",&y); sum[T]--; computer[T][y]=0; @@ -169,7 +169,7 @@ else /* /*È¡ÏûÔ¤¶©*/ void Cancel() { -int time,number; +int time,number,i; printf("ÔÚ(8-20)ʱ¼ä·¶Î§ÄÚÊäÈëÄãÒѾ­Ô¤¶¨µÄʱ¼ä:"); scanf("%d",&time); if(time<8||time>20) @@ -179,11 +179,42 @@ printf("\t scanf("%d",&time); } else -{printf("\tÊäÈëÄãÔ¤¶¨µÄ»úºÅ :"); +{printf("\tÊäÈëÄãÒÑÔ¤¶¨µÄ»úºÅ :"); scanf("%d",&number);} sum[T]++; /*È¡ÏûÔ¤¶¨ºó¸Ãʱ¼ä¶Î¿Õ»úλÊý¼Ó1*/ computer[T][number]=1; /*È¡ÏûÔ¤¶¨ºó¸Ã»ú״̬±äΪ1*/ //detail(time); +FILE *fp; +if((fp=fopen("waitlist.txt","r"))==NULL) /*´ò¿ªÎļþ*/ + { + printf("\nCannot open file!\n"); + exit(0); + } +else + { + for(i=0;!feof(fp);i++) + { + fscanf(fp,"%s %s",&wait[i].number,&wait[i].telephonenumber); + } + fclose(fp); + } +for(i=0;i<10;i++) +{ + char str[3]; + itoa(number,str,10); /*µ÷ÓÃitoaº¯Êý£¬ÊµÏÖÊý¾Ý´æÈë*/ + //printf("\n %s" ,&wait[i].number) ; + //printf("\n %s" ,&str) ; + if (strcmp(wait[i].number,str)==0 ) /*ÅжÏҪȡÏûµÄ»úºÅÊÇ·ñÓëÒѼÈëµÄ»úºÅÏàͬ*/ + { + wait[i]=wait[i+1]; + printf("È¡ÏûµÈ´ý%s %s",&wait[i-1].number,&wait[i-1].telephonenumber); + } + +} +fp=fopen("waitlist.txt","w"); +for(i=0;i<1;i++) + fwrite(&wait[i],sizeof(struct waitlist),1,fp); /*ÖØÐÂдÈëÔ¤¶¨ÐÅÏ¢*/ +fclose(fp); printf("\tÈ¡Ïû³É¹¦!\n"); getchar(); Menu(); @@ -209,10 +240,10 @@ printf("\nCannot open file!\n"); exit(0); } else -{ printf("µÈ´ýÐÅÏ¢:\t»úºÅ\tµÈ´ýÊÖ»úºÅÂë\n"); /*Êä³öµÈ´ýÐÅÏ¢*/ +{ printf("ÔÚ¸Ãʱ¶ÎÒÑÁÐÈëµÈ´ýÁбíµÄµçÄÔ:\t»úºÅ\n"); for(i=0;!feof(fp);i++) { -fscanf(fp,"%s %s",&wait[i].number,&wait[i].telephonenumber); +fscanf(fp,"%s %s",&wait[i].number,&wait[i].telephonenumber); /*¸üеȴýÐÅÏ¢*/ } fclose(fp); } @@ -237,8 +268,8 @@ printf("\tÄ¿Ç° for(k=0;k