欢迎来到蒟蒻mqd的博客

教室管理系统(极其简陋)

  1 #include<bits/stdc++.h>
  2 #include<windows.h>
  3 #include<conio.h>
  4 #include "mmsystem.h"//导入声音头文件
  5 #pragma comment(lib,"winmm.lib")//导入声音头文件库
  6 //   0 = 黑色      8 = 灰色
  7 //   1 = 蓝色      9 = 淡蓝色
  8 //   2 = 绿色      A = 淡绿色
  9 //   3 = 浅绿色    B = 淡浅绿色
 10 //   4 = 红色      C = 淡红色
 11 //   5 = 紫色      D = 淡紫色
 12 //   6 = 黄色      E = 淡黄色
 13 //   7 = 白色      F = 亮白色
 14 //   10= 亮绿 
 15 //   12= 亮红 
 16 //   控制台前景颜色
 17 struct Room 
 18 {
 19     int cap;
 20     int c[7][4];
 21 }room[200];
 22 char *sub[]={"","高等数学","英语    ","c语言   ","思修    "}; 
 23 char *cou[]={"","高等数学","英语","c语言","思修"}; 
 24 void set_position(int x,int y,int n,int m)//重置窗口大小 
 25 {
 26     HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE); 
 27     SMALL_RECT rc = {x,y,n, m}; // 重置窗口位置和大小
 28     SetConsoleWindowInfo(hout,true ,&rc);
 29 }
 30 void hide()//隐藏光标 
 31 {
 32     HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
 33     CONSOLE_CURSOR_INFO x={1,0};
 34     SetConsoleCursorInfo(hout, &x);
 35 }
 36 
 37 void change_color(int a, int b)//设置颜色,a为字体颜色,b为背景色 
 38 {
 39     HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
 40     SetConsoleTextAttribute(handle, a | b);
 41 }
 42 using namespace std;
 43 void read(int &x,int &pd)//读入整数X,读到了整数pd为1,否则为0 
 44 {
 45     int fh=1;pd=0;
 46     char c;x=0;
 47     while(!isdigit(c=getchar())&&c!='-'&&c!='\n'&&c!=EOF);
 48     if (c=='-'){fh=-1;c=getchar();}
 49     while(isdigit(c))x=x*10+c-'0',c=getchar(),pd=1;
 50     x*=fh;
 51 }
 52 void gotoxy(int x,int y)//指定位置输出 
 53 {
 54     COORD pos;  
 55     pos.X=x;  
 56     pos.Y=y;  
 57     //CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
 58     HANDLE h;
 59     h= GetStdHandle(STD_OUTPUT_HANDLE);
 60     SetConsoleCursorPosition(h,pos);
 61 }
 62 void play(char *s,int delay)//延时输出字符数组 
 63 {
 64     int len=strlen(s);
 65     clock_t start,pause;
 66     start=clock();
 67     for(int i=0;i<len;)
 68     {
 69         if((pause=clock())-start>=delay)
 70         {
 71             printf("%c",s[i++]); 
 72             //cout<<s[i++];
 73             start=pause;
 74         }
 75     }
 76 }
 77 void ssplay(int x,int y,char *s,int cnt )//在(x,y)输出s,闪烁cnt次 
 78 {
 79     char *ss="                      ";
 80     for(int i=1;i<=cnt;i++)
 81     {
 82         gotoxy(x,y); play(ss,0); 
 83         Sleep(100);
 84         gotoxy(x,y); play(s,0);     
 85         Sleep(100);
 86         
 87     }
 88 }
 89 void hx_char(char *s,int x,int y,int n,int m,int xx,int yy,int delay)//回形输出,起点(x,y),终点(xx,yy),长为m,高为n
 90 {
 91     int lx[4]={1,0,-1,0};
 92     int ly[4]={0,1,0,-1};
 93     bool f[300][300]; 
 94     memset(f,0,sizeof(f));
 95     int i=x,j=y,k=0;
 96     gotoxy(i,j);play(s,delay); f[i][j]=1;
 97     while(i!=xx||j!=yy)
 98     {
 99         while(f[lx[k]+i][ly[k]+j]==1||lx[k]+i>=x+m||lx[k]+i<x||ly[k]+j>=y+n||ly[k]+j<y)k=(k+1)%4;
100         i+=lx[k]; j+=ly[k];
101         f[i][j]=1;
102         gotoxy(i,j);
103         play(s,delay);
104         //gotoxy(x+2,y+20);
105         //printf("%d %d %d %d %d %d ",i,j,k,xx,yy,f[i+lx[k]][j+ly[k]]);
106     }
107 }
108 void hx_string(char s[][120],int x,int y,int n,int m,int xx,int yy,int delay)//回形输出,起点(x,y),终点(xx,yy),长为m,高为n,宣告报废 
109 {
110     int lx[4]={2,0,-2,0};
111     int ly[4]={0,1,0,-1};
112     bool f[300][300]; 
113     memset(f,0,sizeof(f));
114     int i=x,j=y,k=0;
115     char ss[]={"a"};ss[0]=s[i][j]; 
116     gotoxy(i,j);play(ss,delay); f[i][j]=1;
117     while(i!=xx||j!=yy)
118     {
119         while(f[lx[k]+i][ly[k]+j]==1||lx[k]+i>=x+m||lx[k]+i<x||ly[k]+j>=y+n||ly[k]+j<y)k=(k+1)%4;
120         i+=lx[k]; j+=ly[k];
121         f[i][j]=1;
122         if (k==0){gotoxy(i,j);printf("%c%c",s[j][i],s[j][i+1]);}
123         if (k==2){gotoxy(i-1,j);printf("%c%c",s[j][i-1],s[j][i]);}
124         if (k==1||k==3){gotoxy(i,j);printf("%c",s[j][i]);}
125         Sleep(delay); 
126         //gotoxy(i,j); ss[0]=s[j][i]; play(ss,delay);
127         //gotoxy(x+2,y+20);
128         //printf("%d %d %d %d %d %d ",i,j,k,xx,yy,f[i+lx[k]][j+ly[k]]);
129     }
130 }
131 void start_concole()//加载动画 
132 {
133     char *s[4]={"<欢迎来到教室信息管理系统>","制作人: 孟强定,  任梦石, 麦麦提, 吴凡, 李嘉璐","希望你能喜欢!!!!!!!!!!!!","如果不喜欢请按alt+F4"};
134     gotoxy(45,4);change_color(10,0);play(s[0],20);
135     change_color(8,0);hx_char("*",20,5,14,75,20,6,10);
136     change_color(11,0);
137     gotoxy(25,7);play(s[1],20);
138     gotoxy(25,9);play(s[2],20);
139     gotoxy(25,11);play(s[3],20);
140     change_color(1,192);gotoxy(50,13);printf("加载中");for(int i=1;i<=2;i++){gotoxy(56,13);printf("  ");play(". . . . .",250);gotoxy(56,13);play("           ",250);}
141 }
142 void clear()//清空控制台 
143 {
144     change_color(7,0);
145     system("cls");
146 }
147 void main_menu()//宣告报废 
148 {
149     char *ss={"a"};
150     char s[30][120]={};
151     FILE *fin=fopen("main_menu.in","rb");
152     int j=0;
153     for(int i=0;i<19;i++)  
154         {
155             //while(j<97)s[i][j++]=fgetc(fin);
156             while((s[i][j]=fgetc(fin))!='\n') {/*if (s[i][j]=='*'){printf("%d %d\n",i,j);Sleep(1000);}*/j++;}
157             //printf("%d %d %s ",i,strlen(s[i]),s[i]);
158             //printf("%s",s[i]);
159             j=0;
160         }
161     fclose(fin);
162     for(int i=0;i<19;i++)
163     for(int j=0;j<strlen(s[i]);j+=2)
164         {
165             gotoxy(j,i);
166             //printf("%d %d \n",i,j);
167             //if (s[i][j]=' ')printf("@");
168             printf("%c%c",s[i][j],s[i][j+1]);
169             //if (j>=strlen(s[i])-3)
170             //printf("%d",strlen(s[i]));
171             //ss[0]=s[i][j];
172             //play(ss,50);
173             //Sleep(20);
174         }
175     //printf("%c %c\n",s[19][4],s[20][5]);
176 
177     //hx_string(s,20,5,)
178     int xx=26,yy=11,n=2,m=63,x=20,y=5;
179     while(xx!=x-1||yy!=y-1)
180     {
181         //hx_char("*",xx,yy,n,m,xx,yy+1,0);
182         hx_string(s,xx,yy,n,m,xx,yy+1,0);
183         Sleep(200);
184         xx--; yy--;
185         n+=2; m+=2;
186     }
187 }
188 void menu_concole()//菜单信息 
189 {
190     char *s[10]={"初始化          ","教室信息管理    ","课程信息管理    ","教室分配        ","退出            ","关机            "};
191     gotoxy(0,0);
192     change_color(10,0);gotoxy(53,4);  printf("功能菜单");
193     change_color(8,16);hx_char("*",20,6,14,75,20,7,0);
194     int j=0;
195     for(int i=8;i<=18;i+=2)
196     {
197         gotoxy(42,i);
198         change_color(12,0);printf("%s",s[j++]);
199         change_color(7,0);printf("       请按%d",j);
200     }
201      
202 }
203 
204 void water_end()//过场动画 
205 {
206     change_color(8,0);
207     for(int i=17,j=2,n=20,m=81;n+2&&m+2;i++,j++,n-=2,m-=2)
208     {
209         //printf("%d ",n);
210         hx_char(" ",i-1,j-1,n+2,m+2,i-1,j,0);
211         if (m==0||n==0)return ;
212         hx_char("*",i,j,n,m,i,j+1,0);
213         Sleep(40);
214     }
215     Sleep(500);
216 }
217 void water_begin()//暂时不用的过场动画 
218 {
219     
220     //menu_concole();
221     int x=20, y=5,xx=26,yy=12,n=14,m=75;
222     int i=xx,j=yy;
223     while(i!=x||j!=y+1)
224     {
225         //menu_concole();
226         //clear();
227         if (i%2==0) hx_char("|",x,y,n,m,i,j,1);
228         else  hx_char("-",x,y,n,m,i,j,1);
229         Sleep(100);    
230         i--;j--;
231     }
232     printf("!!!!");
233 } 
234 void end()//结束动画 
235 {
236     //system("cls");
237     water_end();
238      change_color(1,112);
239     gotoxy(50,8); printf("欢迎下次再来  !!");
240     gotoxy(50,11); printf("按任意键关闭窗口");
241     gotoxy(50,16);
242     change_color(0,0);
243     exit(0);
244 }
245 void initialize()//初始化 
246 {
247     FILE *fp=fopen("classroom.txt","w");
248     clear(); 
249     for(int i=1;i<=50;i++)
250     {
251         room[i].cap=60;
252         for(int j=1;j<=5;j++)
253         for(int k=1;k<=4;k++)
254             room[i].c[j][k]=rand()%5,fprintf(fp,"%d%c",room[i].c[j][k],k==4?'\n':' ');    
255     }
256     fclose(fp);
257     change_color(1,192);gotoxy(42,13);printf("初始化中请等待");for(int i=1;i<=2;i++){gotoxy(56,13);printf("  ");play(". . . . .",250);gotoxy(56,13);play("           ",250);}
258     clear(); 
259     change_color(12,0);ssplay(47,13,"---初始化成功---",2);
260     Sleep(500);    
261 }
262 void display_room_info(int num,int pd)// 教室信息展示 
263 {
264     //printf("!!!  %d  !!!!",room[nu].c[j][i]);
265     clear();
266     change_color(8,16);hx_char("*",18,5,14,77,18,6,0);
267     char *s[]={"星期","","","","",""};
268     int x=25,y=4; 
269     gotoxy(x-6,y); change_color(10,0);printf("1-%d教室:",num);
270     y+=2;
271     gotoxy(x,y); change_color(11,0);
272     printf("%s    ",s[0]);
273     for(int i=1;i<=4;i++)printf("%s           ",s[i]);
274     printf("%s",s[5]);
275     x-=6;y+=2;gotoxy(x,y);printf("节次"); 
276     for(int i=1;i<=4;i++)
277     for(int j=1;j<=5;j++)
278     {    
279         if (j==1){change_color(11,0);y+=2;gotoxy(x,y);printf("  %d           ",i);}
280         change_color(7,0);printf("%s",sub[room[num].c[j][i]]);
281         if (j==5)continue;
282         printf("     ");
283     }
284     gotoxy(x-4,y+4);
285     //if (pd)system("pause"); 
286     if (pd) {printf("请按任意键退出...");char c=getch();}
287 } 
288 void room_change(int num)//教室更改子目录 
289 {
290     
291     char *s[]={"输入无效数据请重新输入","请输入x y z (x为星期,y为节次,z为课程代号)","退出请输入-1","请在此输入:"}; 
292     int color[]={12,7,7,11};
293     int x,y,z,flag=true,pd,tot=0;
294     while(true)
295     {
296         clear();
297         display_room_info(num,0);
298         gotoxy(18,26);change_color(11,0);if (tot){printf("已成功更改%d次",tot);}
299         int xx=18,yy=19;
300         for(int i=0;i<=3;i++)
301         {
302             gotoxy(xx,yy);
303             change_color(color[i],0);
304             if (i==0&&flag==false)ssplay(xx,yy,s[i],2);
305             if (i!=0)play(s[i],0);
306             yy++;
307         }
308         xx=70,yy=20;
309         change_color(6,0);
310         for(int i=0;i<=4;i++)
311         {
312             yy++;
313             gotoxy(xx,yy);
314             printf("%d:%s",i,sub[i]);    
315         } 
316         change_color(11,0);
317         gotoxy(31,22);
318         read(x,pd);if (x==-1)return; if (pd==0){flag=false;continue;} 
319         read(y,pd);if (pd==0){flag=false;continue;} 
320         read(z,pd);if (pd==0){flag=false;continue;} 
321         if(x<=0||x>5||y<=0||y>4||z< 0||z>4){flag=false;continue;} 
322         flag=true;
323         room[num].c[x][y]=z;    
324         display_room_info(num,0);
325         tot++;
326         //change_color(12,0);play("更改成功",0); 
327         //change_color(7,0);play("是否继续更改y/n",0);
328         //char c=getch();
329         //if (c=='n')return ; 
330     }
331 }
332 void room_manage_change()//教室更改主目录 
333 {
334     int color[]={12,7,7};
335     char *s[20]={"输入无效数据请重新输入","请输入需要更改的教室的编号x (0<x<=50)","退出请输入-1","请在此输入:"};
336     int k=0,pd;
337     while(true)
338     {
339         clear();
340         int x=43,y=9; 
341         for(int i=0;i<=3;i++)
342         {
343             gotoxy(x,y); 
344             if (i!=0){change_color(11,0);printf("");}
345             //printf("%d %d ",i,k);
346             change_color(color[i],0);
347             if (i==0&&k==1)ssplay(x,y,s[i],2);
348             if (i!=0) play(s[i],0);
349             y+=2;
350         }
351         int num;
352         read(num,pd);
353         if (num==-1)return ;
354         if (num<=0||num>50)k=1;
355         if (num>0&&num<=50){room_change(num);k=0;}
356     }
357 }
358 void room_manage_search()//教室查询 
359 {
360     int color[]={12,7,7};
361     char *s[20]={"输入无效数据请重新输入","请输入需要查询的教室的编号x (0<x<=50)","退出请输入-1","请在此输入:"};
362     int k=0,pd=0;
363     while(true)
364     {
365         clear();
366         int x=43,y=9; 
367         for(int i=0;i<=3;i++)
368         {
369             gotoxy(x,y); 
370             if (i!=0){change_color(11,0);printf("");}
371             //printf("%d %d ",i,k);
372             change_color(color[i],0);
373             if (i==0&&k==1)ssplay(x,y,s[i],2);
374             if (i!=0) play(s[i],0);
375             y+=2;
376         }
377         int num;
378         //scanf("%d",&num);
379         read(num,pd);
380         if (num==-1)return ;
381         if (num<=0||num>50)k=1;
382         if (num>0&&num<=50){display_room_info(num,1);k=0;}
383     }
384 }
385 
386 void room_manage()//教室信息管理主菜单 
387 {
388 
389     char *s[20]={"|              |"," 查询   请按1 "," 更改   请按2 "," 退出   请按3 ","|_            _|","教室信息管理"}; 
390     int delay=20;
391     while(true)
392     {
393         clear();
394         gotoxy(50,4);change_color(10,0);play(s[5],0);
395         change_color(8,16);hx_char("*",20,6,14,75,20,7,0);
396         int x=47,y=9;    
397         for(int i=1;i<=3;i++,y+=2)
398         {
399             gotoxy(x,y);change_color(12,0);play(s[0],0);
400             gotoxy(x,y+1); 
401             change_color(12,0);  play("|",0);
402             change_color(7,0);   play(s[i],delay);
403             change_color(12,0);  play("|",0);
404             
405         }
406         gotoxy(x,y);change_color(12,0);play(s[4],0);
407         char s=getch();
408         if (s=='1') room_manage_search();
409         if (s=='2') room_manage_change();
410         if (s=='3') return;
411         delay=0;
412     }
413     
414 }
415 bool sub_judge(int x,int y,int z,int d)//判断教室 
416 {
417     return room[x].c[y][z]==d?true:false;
418 }
419 void display_course_info(int kx,int ky,int z,int pd,int &cnt)// 教室信息展示 
420 {
421     //printf("!!!  %d  !!!!",room[nu].c[j][i]);
422     char *s[]={"",""}; 
423     clear();
424     change_color(8,16);hx_char("*",18,5,14,77,18,6,0);
425     int x=25,y=4;
426     cnt=0; 
427     gotoxy(x-6,y); change_color(10,0);
428     printf("星期%d,第%d节课,%s%s课的教室:",kx,ky,z==0?s[0]:s[1],cou[z]);
429      y+=4;
430     gotoxy(x,y); change_color(11,0);
431     for(int i=1;i<=50;i++)
432     {
433         if (room[i].c[kx][ky]==z){printf("%-2d:%2d教室    ",++cnt,i);if (cnt%5==0){y+=2;gotoxy(x,y);}}
434     }
435     if (cnt==0)printf("无!!!"); 
436     gotoxy(18,20);
437     //if (pd)system("pause"); 
438     if (pd) {printf("请按任意键退出...");gotoxy(0,0);char c=getch();}
439     
440 } 
441 void course_change(int kx,int ky,int z)//课程更改子目录 
442 {
443     char *s[20]={"输入无效数据请重新输入","请输入x y(x为教室号,y为所改课程)","退出请输入-1","请在此输入:"};
444     int color[]={12,7,7,11};
445     int rom,course,tot=0,flag=true,pd,cnt; 
446     while(true)
447     {
448         display_course_info(kx,ky,z,0,cnt);
449         gotoxy(18,26);if (tot){printf("已成功更改%d次",tot);}
450         int x=18,y=20;
451         for(int i=0;i<=3;i++)
452         {
453             gotoxy(x,y);
454             change_color(color[i],0);
455             if (i==0&&flag==false)ssplay(x,y,s[i],2);
456             if (i!=0)play(s[i],0);
457             y++;
458         }
459         change_color(6,0);
460         x=70;y=20;
461         for(int i=0;i<=4;i++)
462         {
463             y++;
464             gotoxy(x,y);
465             printf("%d:%s",i,sub[i]);    
466         } 
467         change_color(11,0);gotoxy(29,23);
468         read(rom,pd);if (pd==0){flag=false;continue;}if (rom==-1)return;
469         read(course,pd);if (pd==0){flag=false;continue;} 
470         if (rom<=0||rom>50||course<0||course>4||cnt==0||sub_judge(rom,kx,ky,z)==false){flag=false;continue;}
471         flag=true;
472         room[rom].c[kx][ky]=course;
473         tot++;    
474     }
475 }
476 void course_manage_change()//课程更改主目录 
477 {
478     int color[]={12,7,7,12};
479     char *s[20]={"输入无效数据请重新输入","请输入x y z(x为星期,y为节次,z为课程代号)","退出请输入-1","请在此输入:"};
480     int pd=0,flag=0,kx,ky,z,num,tot=0;
481     while(true)
482     {
483         clear();
484         int x=43,y=9; 
485         for(int i=0;i<=3;i++)
486         {
487             gotoxy(x,y); 
488             if (i!=0){change_color(11,0);printf("");}
489             //printf("%d %d ",i,k);
490             change_color(color[i],0);
491             if (i==0&&flag==1)ssplay(x,y,s[i],2);
492             if (i!=0) play(s[i],0);
493             y+=2;
494         }
495         change_color(6,0);
496         x=20;y=10;
497         for(int i=0;i<=4;i++)
498         {
499             y++;
500             gotoxy(x,y);
501             printf("%d:%s",i,sub[i]);    
502         } 
503         flag=0;
504         gotoxy(56,15);
505         change_color(11,0);
506         read(kx,pd);if (kx==-1)return ;if (pd==0){flag=1;continue;} 
507         read(ky,pd);if (pd==0){flag=1;continue;} 
508         read(z,pd);if (pd==0){flag=1;continue;} 
509         if(kx<=0||kx>5||ky<=0||ky>4||z< 0||z>4){flag=1;continue;}     
510         course_change(kx,ky,z);
511         //if (num<=0||num>50)k=1;
512         //if (num>0&&num<=50){display_room_info(num,1);k=0;}
513     }
514 }
515 void course_manage_search()//课程查询 
516 {
517     int color[]={12,7,7,12};
518     char *s[20]={"输入无效数据请重新输入","请输入x y z(x为星期,y为节次,z为课程代号)","退出请输入-1","请在此输入:"};
519     int pd=0,flag=0,kx,ky,z,num,cnt;
520     while(true)
521     {
522         clear();
523         int x=43,y=9; 
524         for(int i=0;i<=3;i++)
525         {
526             gotoxy(x,y); 
527             if (i!=0){change_color(11,0);printf("");}
528             //printf("%d %d ",i,k);
529             change_color(color[i],0);
530             if (i==0&&flag==1)ssplay(x,y,s[i],2);
531             if (i!=0) play(s[i],0);
532             y+=2;
533         }
534         change_color(6,0);
535         x=20;y=10;
536         for(int i=0;i<=4;i++)
537         {
538             y++;
539             gotoxy(x,y);
540             printf("%d:%s",i,sub[i]);    
541         } 
542         flag=0;
543         gotoxy(56,15);
544         change_color(11,0);
545         read(kx,pd);if (kx==-1)return ;if (pd==0){flag=1;continue;} 
546         read(ky,pd);if (pd==0){flag=1;continue;} 
547         read(z,pd);if (pd==0){flag=1;continue;} 
548         if(kx<=0||kx>5||ky<=0||ky>4||z< 0||z>4){flag=1;continue;}     
549         display_course_info(kx,ky,z,1,cnt);
550         //if (num<=0||num>50)k=1;
551         //if (num>0&&num<=50){display_room_info(num,1);k=0;}
552     }
553 }
554 void course_manage()//课程信息管理主菜单 
555 {
556     char *s[20]={"|              |"," 查询   请按1 "," 更改   请按2 "," 退出   请按3 ","|_            _|","课程信息管理"}; 
557     int delay=20;
558     while(true)
559         {
560         clear();
561         gotoxy(50,4);change_color(10,0);play(s[5],0);
562         change_color(8,16);hx_char("*",20,6,14,75,20,7,0);
563         int x=47,y=9;    
564         for(int i=1;i<=3;i++,y+=2)
565         {
566             gotoxy(x,y);change_color(12,0);play(s[0],0);
567             gotoxy(x,y+1); 
568             change_color(12,0);  play("|",0);
569             change_color(7,0);   play(s[i],delay);
570             change_color(12,0);  play("|",0);
571             
572         }
573         gotoxy(x,y);change_color(12,0);play(s[4],0);
574         char s=getch();
575         if (s=='1') course_manage_search();
576         if (s=='2') course_manage_change();
577         if (s=='3') return;
578         delay=0;
579     }
580 }
581 void room_distribute_low()
582 {
583         int color[]={12,7,7,12};
584     char *s[20]={"输入无效数据请重新输入","请输入x y (x为星期,y为节次)","退出请输入-1","请在此输入:","人工分配"};
585     int pd=0,flag=0,kx,ky,num;
586     while(true)
587     {
588         clear();
589         gotoxy(50,4);change_color(10,0);play(s[4],0);
590         change_color(8,16);hx_char("*",20,6,14,75,20,7,0);
591         int x=43,y=9; 
592         //for(int i=1;i<=50;i++)if (room[i].c[) 
593         for(int i=0;i<=3;i++)
594         {
595             gotoxy(x,y); 
596             if (i!=0){change_color(11,0);printf("");}
597             //printf("%d %d ",i,k);
598             change_color(color[i],0);
599             if (i==0&&flag==1)ssplay(x,y,s[i],2);
600             if (i!=0) play(s[i],0);
601             y+=2;
602         }
603         flag=0;
604         gotoxy(56,15);
605         change_color(11,0);
606         read(kx,pd);if (kx==-1)return ;if (pd==0){flag=1;continue;} 
607         read(ky,pd);if (pd==0){flag=1;continue;} 
608         if(kx<=0||kx>5||ky<=0||ky>4){flag=1;continue;}     
609         course_change(kx,ky,0);
610         //if (num<=0||num>50)k=1;
611         //if (num>0&&num<=50){display_room_info(num,1);k=0;}
612     }
613 } 
614 void distribute(int kx,int ky,int num,int course)//自动分配 
615 {
616     for(int i=1;i<=50&&num>0;i++)
617     {
618         if (room[i].c[kx][ky]==0){room[i].c[kx][ky]=course;num--;}
619     }
620 }
621 void distribute_smart(int kx,int ky)//批量自动分配子目录 
622 {
623     char *s[20]={"输入无效数据请重新输入","请输入x y(x为教室号数量,y为所改课程)","退出请输入-1","请在此输入:"};
624     int color[]={12,7,7,11};
625     int num,course,tot=0,flag=true,pd,cnt; 
626     while(true)
627     {
628         display_course_info(kx,ky,0,0,cnt);
629         gotoxy(18,26);if (tot){printf("已成功更改%d次",tot);}
630         int x=18,y=20;
631         for(int i=0;i<=3;i++)
632         {
633             gotoxy(x,y);
634             change_color(color[i],0);
635             if (i==0&&flag==false)ssplay(x,y,s[i],2);
636             if (i!=0)play(s[i],0);
637             y++;
638         }
639         change_color(6,0);
640         x=70;y=20;
641         for(int i=0;i<=4;i++)
642         {
643             y++;
644             gotoxy(x,y);
645             printf("%d:%s",i,sub[i]);    
646         } 
647         gotoxy(29,23); change_color(11,0);
648         read(num,pd);if (pd==0){flag=false;continue;}if (num==-1)return;
649         read(course,pd);if (pd==0){flag=false;continue;} 
650         if (num<=0||num>cnt||course<=0||course>4){flag=false;continue;}
651         distribute(kx,ky,num,course);
652         tot++;
653     }
654 }
655 void room_distribute_smart()//批量自动分配主目录 
656 {
657     int color[]={12,7,7,12};
658     char *s[20]={"输入无效数据请重新输入","请输入x y (x为星期,y为节次)","退出请输入-1","请在此输入:","批量分配"};
659     int pd=0,flag=0,kx,ky,num;
660     while(true)
661     {
662         clear();
663         gotoxy(50,4);change_color(10,0);play(s[4],0);
664         change_color(8,16);hx_char("*",20,6,14,75,20,7,0);
665         int x=43,y=9; 
666         //for(int i=1;i<=50;i++)if (room[i].c[) 
667         for(int i=0;i<=3;i++)
668         {
669             gotoxy(x,y); 
670             if (i!=0){change_color(11,0);printf("");}
671             //printf("%d %d ",i,k);
672             change_color(color[i],0);
673             if (i==0&&flag==1)ssplay(x,y,s[i],2);
674             if (i!=0) play(s[i],0);
675             y+=2;
676         }
677         flag=0;
678         gotoxy(56,15);
679         change_color(11,0);
680         read(kx,pd);if (kx==-1)return ;if (pd==0){flag=1;continue;} 
681         read(ky,pd);if (pd==0){flag=1;continue;} 
682         if(kx<=0||kx>5||ky<=0||ky>4){flag=1;continue;}     
683         distribute_smart(kx,ky);
684         //if (num<=0||num>50)k=1;
685         //if (num>0&&num<=50){display_room_info(num,1);k=0;}
686     }
687 }
688 void room_distribute()//教室分配 
689 {
690     char *s[20]={"|                  |"," 批量分配   请按1 "," 人工分配   请按2 "," 退出       请按3 ","|_                _|","课程信息管理"}; 
691     int delay=20;
692     while(true)
693         {
694         clear();
695         gotoxy(50,4);change_color(10,0);play(s[5],0);
696         change_color(8,16);hx_char("*",20,6,14,75,20,7,0);
697         int x=47,y=9;    
698         for(int i=1;i<=3;i++,y+=2)
699         {
700             gotoxy(x,y);change_color(12,0);play(s[0],0);
701             gotoxy(x,y+1); 
702             change_color(12,0);  play("|",0);
703             change_color(7,0);   play(s[i],delay);
704             change_color(12,0);  play("|",0);
705             
706         }
707         gotoxy(x,y);change_color(12,0);play(s[4],0);
708         char s=getch();
709         if (s=='1') room_distribute_smart();
710         if (s=='2') room_distribute_low();
711         if (s=='3') return;
712         delay=0;
713     }
714 } 
715 int main()
716 {  
717     //system("start 1.mp3");
718     set_position(0,0,120,25);//设置控制台大小 
719     SetConsoleTitleA("教室信息管理系统---CUMTB 1.0");//设置控制台标题 
720     clear();
721     hide();
722     start_concole(); water_end(); Sleep(200);
723     //water_begin();
724     while(true) 
725     {
726         clear();
727         menu_concole();
728         //gotoxy(21,20);printf("请在此输入:"); 
729         char s=getch();
730         if (s=='1') initialize();
731         if (s=='2') room_manage();
732         if (s=='3') course_manage();
733         if (s=='4') room_distribute();
734         if (s=='5')end();
735         if (s=='6')system("shutdown -s -c '你咋这么皮呢!!!'");
736         if (s=='7')system("shutdown -a");    
737     }
738     return 0;
739 }
View Code

 

posted @ 2019-06-15 10:19  mmqqdd  阅读(750)  评论(0编辑  收藏  举报