commit 64aa854310a136d84f95d1535d4a3bb43e868ba6 Author: 1021678520aA <18408000504@stu.hut.edu.cn> Date: Wed Jan 9 12:24:16 2019 +0800 first commit diff --git a/gmon.out b/gmon.out new file mode 100644 index 0000000..027529b Binary files /dev/null and b/gmon.out differ diff --git a/学生信息.txt b/学生信息.txt new file mode 100644 index 0000000..0039897 Binary files /dev/null and b/学生信息.txt differ diff --git a/机房机位预订系统.cpp b/机房机位预订系统.cpp new file mode 100644 index 0000000..b645afa --- /dev/null +++ b/机房机位预订系统.cpp @@ -0,0 +1,255 @@ +#include +#include +#include + +#define C 20 //̨ +#define T (time-8)/2 //Ԥʱηֳɰʽ + +void JIEMIAN(); +void XINXI(); +void YUDING(); +void QUXIAO(); +void CHAXUN(); +void slove(int time); +void dengdai(int i); + +int x[6]={0}; +int jiwei[6][20]={ +{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1}, +{1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1}, +{1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,0}, +{1,0,0,0,0,0,0,1,1,1,0,1,0,1,0,1,1,1,1,0}, +{1,1,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1}, +{1,1,0,1,1,1,0,1,0,1,0,1,0,1,1,0,0,0,0,0}};//0Ϊջλ1ΪлλΪijijβѯϵͳʱĻλ + +struct wait{ + char number[3]; + char haoma[20]; +}w[C];//ȴĽṹ +int main(void) +{ +JIEMIAN(); + +return 0; + } +void JIEMIAN() + { + int n,a; + do + { + printf("\t\tλԤԼϵͳ\n"); + puts("\t\t ˵"); + puts("\t\t\t 1.ѯijʱλλϢ."); + puts("\t\t\t 2.Ԥһջλ."); + puts("\t\t\t 3.ȡԤ."); + puts("\t\t\t 4.ѯȴϢ."); + puts("\t\t\t 5.˳ϵͳ."); + puts("\t\t\n"); + printf("\t˵ڵ1-5ѡз:\n"); + scanf("%d",&n); + if(n<1||n>5) + { + a=1; + printf("ѡ."); + getchar(); + } + else + a=0; + }while(a==1); + switch(n) + { + case 1:XINXI();break; + case 2:YUDING();break; + case 3:QUXIAO();break; + case 4:CHAXUN();break; + case 5:exit(0);break; + } + } + void XINXI() + { + int time; + printf("8-20ʱ:"); + scanf("%d",&time); + if(time<8||time>=20) + { + printf(" \n"); + printf(" ȷʱ!"); + XINXI(); + } + if(time>=8&&time<20) + { + slove (time); + JIEMIAN(); +} + } + void YUDING() + { + int time,i,a,b; + char c; + FILE *fp; //ļݡ + printf("8-20ʱڣԤʱ:"); + scanf("%d",&time); + if(time<8||time>=20) + { + printf(" ʱ\n"); + printf(" ȷʱ!\n"); + printf("8-20ʱڣԤʱ:"); + scanf("%d",&time); + } + slove(time); + i=0; + if(x[T]>0) + { + if((fp=fopen("ѧϢ.txt","a"))==NULL) + { + printf("-޷ļ!-\n"); + exit(0); + } + printf(" ҪԤĻλź͵绰(λź͵绰֮ʹÿո)"); + scanf("%s %s",w[i].number,w[i].haoma); + for(i=0;i<1;i++) + fwrite(&w[i],sizeof(struct wait),1,fp); + fclose(fp); //һṹ嵥Ԫļ + printf("\t\t ٴҪԤĻλ!(ʱͬȻܵԤʧܣ)\n"); + scanf("%d",&a); + getchar(); + x[T]--; + jiwei[T][a-1]=1; + printf(" Ԥɹ\n"); + JIEMIAN(); + } + else + { + printf("\n\t ʱûбԤĵԣ\n"); + for(i=T+1;i<6;i++) + { + time=9+2*i; + slove(time); + if(x[T]>0) + printf("\t Ŀеʱǣ%d\n",2*i+8); + break; + } + printf("\t ҪԤ(y/nʾǷԤ)\n"); + scanf("%s",&c); + getchar(); + if(c=='Y'||c=='y') + { + if((fp=fopen("ѧϢ.txt","r"))==NULL) + { + printf("-޷ļ!-\n"); + exit(0); + } + else + { + printf("ǵȴбλ 绰\n"); + for(i=0;!feof(fp);i++) + { + fscanf(fp,"%s %s",&w[i].number,&w[i].haoma); + } + fclose; + } + for(i=0;i<10;i++) + { + dengdai(i); + } + printf("\n\t\t ԤĻλźϵʽ\n"); + if((fp=fopen("ѧϢ.txt","a"))==NULL) + { + printf("-޷ļ!-\n"); + exit(0); + } + scanf("%s %s",w[i].number,w[i].haoma); + for(i=0;i<1;i++) + { + fwrite(&w[i],sizeof(struct wait),1,fp); + fclose(fp); + } + printf("ٴҪԤĻλţ\n"); + scanf("%d",&b); + x[T]--;//һ + jiwei[T][b]=1; + printf("\t ϲԤɹ㽫ȴбȴϵ㡣\n"); + JIEMIAN(); + } + else JIEMIAN(); + } + } + void QUXIAO() + { + int time,n; + printf("8-20ʱѾԤʱ䣺\n"); + scanf("%d",&time); + if(time<8||time>=20) + { + printf(" ʱ\n"); + printf(" ȷʱ!"); + scanf("%d",&time); + } + if(time>=8&&time<20) + { + printf("\t ԤĻţ\n"); + scanf("%d",&n); + } + x[T]++; + jiwei[T][n-1]=0; + slove(time); + printf("\t ȡɹ\n"); + JIEMIAN(); +} +void CHAXUN() + { + int time,i; + FILE *fp; + printf(" Ҫҵʱ(8-20)\n"); + scanf("%d",&time); + if(time<8||time>=20) + { + printf(" ʱ\n"); + printf(" ȷʱ!"); + scanf("%d",&time); + } + if(time>=8&&time<20) + { + if((fp=fopen("ѧϢ.txt","r"))==NULL) + { + printf("-޷ļ!-\n"); + exit(0); + } + else + { + for(i=0;!feof(fp);i++) + { + fscanf(fp,"%s %s",&w[i].number,&w[i].haoma); + } + fclose; + } + for(i=0;i<10;i++) + { + dengdai(i); + } + JIEMIAN(); + } + } +void dengdai(int i) + { + printf("\t\t %s %s \n",w[i].number,w[i].haoma); + } + void slove(int time) //ʱÿʱεĿջλ + { + int i,j=0,k,l=0; + int a[50]; + for(i=0;i<20;i++) + { + if(jiwei[T][i]==0) + { + l++; + a[j++]=i; + } + } + x[T]=l; + printf("\t Ŀǰڿõĵ̨Ϊ%d\n",x[T]); + for(k=0;k