|
|
|
@ -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.查询某时间段机位状态|"); /*查询某时间段机位状态*/
|
|
|
|
|
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<j;k++)
|
|
|
|
|
printf("\t空置的电脑是:%d\n",v[k]);
|
|
|
|
|
}
|
|
|
|
|
void prione(int i) /*实现输出等待列表到屏幕*/
|
|
|
|
|
void prione(int i) /*实现输出等待列表*/
|
|
|
|
|
{
|
|
|
|
|
printf("\t\t %s\t %s\n",wait[i].number,wait[i].telephonenumber);
|
|
|
|
|
printf("\t\t\t\t %s\n",wait[i].number);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|