You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ps7mzffvt/C语言课程设计.c

245 lines
6.0 KiB

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 20 /*<2A><EFBFBD>壺20̨<30><CCA8><EFBFBD><EFBFBD>*/
#define T ((time-8)/2) /*<2A><EFBFBD><EFBFBD><E5A3BA>timeת<65><D7AA>Ϊʱ<CEAA><CAB1><EFBFBD><EFBFBD>*/
int sum[6]={20,20,20,20,20,20}; /*<2A><>ʼ״̬*/
int computer[6][20]={
{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,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,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,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}}; /*<2A><>ʼ״̬<D7B4><CCAC><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>*/
void Menu(); /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6BAAF>*/
void Situation(); /*ʱ<><CAB1><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>*/
void Book(); /*Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
void Cancel(); /*ȡ<><C8A1>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
void SearchWaiting(); /*<2A><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>*/
void detail(int time); /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
void prione(int i); /*ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>*/
struct waitlist /*<2A><EFBFBD><E1B9B9>ʵ<EFBFBD>ֵȴ<D6B5><C8B4>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>*/
{
char number[3]; /*Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
char telephonenumber[11]; /*Ԥ<><D4A4><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>*/
} wait[N];
void printone(int i); /*ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>Ļ*/
int main()
{
Menu(); /*<2A><>ǰ״̬<D7B4><CCAC><EFBFBD><EFBFBD>*/
}
void Menu() /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
{
int n,w;
do
{
puts("\t\t****************<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λԤԼϵͳ*********************\n");
puts("\t\t*********************<2A>˵<EFBFBD>****************************\n");
puts("\t\t\t |1.<2E><>ѯijʱ<C4B3><CAB1><EFBFBD>λ<EFBFBD>λ״̬|"); /*<2A><>ѯijʱ<C4B3><CAB1><EFBFBD>λ<EFBFBD>λ״̬*/
puts("\t\t\t |2.Ԥ<><D4A4><EFBFBD>ջ<EFBFBD>λ\t\t|"); /*Ԥ<><D4A4><EFBFBD>ջ<EFBFBD>λ*/
puts("\t\t\t |3.ȡ<><C8A1>Ԥ<EFBFBD><D4A4>\t\t|"); /*ȡ<><C8A1>Ԥ<EFBFBD><D4A4>*/
puts("\t\t\t |4.<2E><>ѯ<EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>Ϣ\t|"); /*<2A><>ѯ<EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>Ϣ*/
puts("\t\t\t |5.<2E>˳<EFBFBD>\t\t|\n"); /*<2A>˳<EFBFBD>*/
puts("\t\t*****************************************************\n");
printf("ѡ<EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD>(1-5):");
scanf("%d",&n);
if(n<1||n>5)
{w=1;printf("<EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");getchar();}
else
w=0;
}while(w==1);
switch(n)
{
case 1:Situation();break;
case 2:Book();break;
case 3:Cancel();break;
case 4:SearchWaiting();break;
case 5:exit(0);break;
}
getchar();
}
/*ʱ<><CAB1><EFBFBD><EFBFBD>ѯ*/
void Situation()
{
int time;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (8-20)<29><>Χ<EFBFBD>ڵ<EFBFBD>ʱ<EFBFBD><CAB1>:");
scanf("%d",&time);
if(time<8||time>20)
{printf("\tʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (8-20)<29><>Χ<EFBFBD>ڵ<EFBFBD>ʱ<EFBFBD><CAB1>:");
scanf("%d",&time);
}
detail(time); /*<2A><><EFBFBD><EFBFBD>detail<69><6C><EFBFBD><EFBFBD>*/
getchar();
Menu();
}
/*Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
void Book()
{
int time,i=0,x,y;
FILE *fp; /*<2A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ָ<EFBFBD><D6B8>*/
char c;
printf("<EFBFBD><EFBFBD>(8-20)ʱ<>Χ<E4B7B6><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪԤ<D2AA><D4A4><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>:");
scanf("%d",&time);
if(time<8||time>20)
{
printf("\tʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
printf("\t<EFBFBD><EFBFBD>(8-20)ʱ<>Χ<E4B7B6><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪԤ<D2AA><D4A4><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>:");
scanf("%d",&time);
}
detail(time); /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀǰ<C4BF>õ<EFBFBD><C3B5><EFBFBD>*/
if(sum[T]>0) /*<2A><>ʱ<EFBFBD>δ<EFBFBD><CEB4><EFBFBD>δ<EFBFBD><CEB4>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD>*/
{ if((fp=fopen("waitlist.txt","a"))==NULL) /*<2A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>*/
{
printf("\n<EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>!\n");
exit(0);
}
printf("\n\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪԤ<EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ绰<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
scanf("%s %s",wait[i].number,wait[i].telephonenumber);
//for(i=0;i<1;i++)
fwrite(&wait[i],sizeof(struct waitlist),1,fp); /*<2A><><EFBFBD>ı<EFBFBD><C4B1>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>嵥Ԫ*/
fclose(fp); /*<2A>ر<EFBFBD><D8B1>ļ<EFBFBD>*/
printf("<EFBFBD>ٴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
scanf("%d",&x);
sum[T]--; /*Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>οջ<CEBF>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>1*/
computer[T][x]=0; /*Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>״̬<D7B4><CCAC>Ϊ0*/
printf("\tԤ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!\n");
getchar();
Menu();
}
else /*<2A><>ʱ<EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD>*/
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δԤ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>!\n");
for(i=T+1;i<6;i++) /*Ѱ<><D1B0><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ʱ<EFBFBD><CAB1>δ<EFBFBD><CEB4>Ԥ<EFBFBD><D4A4><EFBFBD>ĵ<EFBFBD><C4B5>Ժ<EFBFBD>*/
{ time=9+2*i;
detail(time); /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
if(sum[T]>0) /*<2A><><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><E1B9A9><EFBFBD>Ž<EFBFBD><C5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
printf("\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> %d,%d\n",2*i+8,2*i+10);break;
}
if(sum[T]>0)
{
printf("\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪԤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>?:y/n?");
scanf("%s",&c);
getchar();
if(c=='Y'||c=='y') /*<2A>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>ҪԤ<D2AA><D4A4>*/
{
if((fp=fopen("waitlist.txt","r"))==NULL)
{
printf("\n<EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>!\n");
exit(0);
}
else
{
printf("waitlist<EFBFBD><EFBFBD>number telephonenumber\n");
for(i=0;!feof(fp);i++)
{
fscanf(fp,"%s %s",&wait[i].number,&wait[i].telephonenumber); /*¼<><C2BC>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>Ϣ*/
}
fclose(fp);
}
for(i=0;i<10;i++)
{ prione(i);}
printf("\n\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD>ʽ:\n");
if((fp=fopen("waitlist.txt","a"))==NULL)
{
printf("\n<EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>!\n");
exit(0);
}
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); /*<2A><><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ķ<EFBFBD>ʽ<EFBFBD>г<EFBFBD><D0B3><EFBFBD>ʱ<EFBFBD>ĵȴ<C4B5><C8B4>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD>ϵ<EFBFBD><CFB5>ʽ*/
printf("<EFBFBD>ٴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
scanf("%d",&y);
sum[T]--;
computer[T][y]=0;
printf("\tԤ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD>ȴ<EFBFBD>֪ͨ!\n");
}
}
for(i=T+1;i<6;i++) /*Ѱ<><D1B0><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ʱ<EFBFBD><CAB1>δ<EFBFBD><CEB4>Ԥ<EFBFBD><D4A4><EFBFBD>ĵ<EFBFBD><C4B5>Ժ<EFBFBD>*/
{ time=9+2*i;
detail(time); /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
if(sum[T]>0) break;
else printf("<EFBFBD>ܱ<EFBFBD>Ǹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δԤ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>"); /*<2A><><EFBFBD>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʾ<EFBFBD><CABE>Ϣ*/
}
Menu();
}
//else Menu();
}
/*ȡ<><C8A1>Ԥ<EFBFBD><D4A4>*/
void Cancel()
{
int time,number;
printf("<EFBFBD><EFBFBD>(8-20)ʱ<>Χ<E4B7B6><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>:");
scanf("%d",&time);
if(time<8||time>20)
{
printf("\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
printf("\t<EFBFBD><EFBFBD>(8-20)ʱ<>Χ<E4B7B6><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>:");
scanf("%d",&time);
}
else
{printf("\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD> :");
scanf("%d",&number);}
sum[T]++; /*ȡ<><C8A1>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>οջ<CEBF>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>1*/
computer[T][number]=1; /*ȡ<><C8A1>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>״̬<D7B4><CCAC>Ϊ1*/
//detail(time);
printf("\tȡ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!\n");
getchar();
Menu();
}
/*<2A><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>Ϣ*/
void SearchWaiting()
{
int time,i;
FILE *fp;
printf("\t<EFBFBD><EFBFBD>(8-20)֮<><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>:");
scanf("%d",&time);
if(time<8||time>20)
{
printf("\tʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
printf("\t<EFBFBD><EFBFBD>(8-20)֮<><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>:");
scanf("%d",&time);
}
else
;
if((fp=fopen("waitlist.txt","r"))==NULL) /*<2A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>*/
{
printf("\nCannot open file!\n");
exit(0);
}
else
{ printf("<EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD>Ϣ:\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD>ȴ<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n"); /*<2A><><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>Ϣ*/
for(i=0;!feof(fp);i++)
{
fscanf(fp,"%s %s",&wait[i].number,&wait[i].telephonenumber);
}
fclose(fp);
}
for(i=0;i<10;i++)
{ prione(i);}
Menu();
}
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
void detail(int time) /*ʵ<>ֲ<EFBFBD><D6B2><EFBFBD>ÿ<EFBFBD><C3BF>ʱ<EFBFBD><CAB1><EFBFBD>οջ<CEBF>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>Ϳջ<CDBF>λ<EFBFBD><CEBB>*/
{
int i,j=0,k,s=0;
int v[30];
for(i=0;i<20;i++)
{
if(computer[T][i]==1)
{ s++; /*sΪ<73><CEAA><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
v[j++]=i; /*<2A><><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>λ<EFBFBD><CEBB>*/
}
}
sum[T]=s;
printf("\tĿǰ<EFBFBD><EFBFBD><EFBFBD>õĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d̨\n",sum[T]);
for(k=0;k<j;k++)
printf("\t<EFBFBD><EFBFBD><EFBFBD>õĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%d\n",v[k]);
}
void prione(int i) /*ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>Ļ*/
{
printf("\t\t %s\t %s\n",wait[i].number,wait[i].telephonenumber);
}