c语言_排考场座位问题:
④排考场座位问题:假设考场有8×8的座位,每当一个考生进入考场就为他安排座位。主界面如下:请输入选项(1-4)1?设定考场座位2?取消考场座位3?显示某座位考生信息4?查找学生座位6)?选择1,用户输入准考证号,随机产生该学生座位的行号和列号,要求一个考生只有一个座位,已有考生的位置上不能再安排新的考生;7)?取消某人的考场座位;8)?输入行号列号,输出该考生的准考证号;9)?输入某学生的准考证号,输出该学生的座
#includemain(){?int a[8][8];? ?int i, fuwu;?? ?int count;?? ?int number, x, y;
?for(x=0; x<8; x++)?{??for(y=0; y<8; y++)??{???a[x][y]=0;??}?}
loop:?printf("\n1.she ding kao chang zuo wei\n");?printf("2.qu xiao kao chang zuo wei\n");?printf("3.xiao shi kao sheng xin xi\n");?printf("4.cha zao xue sheng zuo wei\n");
?printf("shu ru nin yao de fu wu\n");???fuwu =getche();?switch(fuwu)?{?case '1':??printf("please input your number\n");??scanf("%d",&number);??for(;a[x][y] >0;)??{???x =rand()%8;???y =rand()%8;??}??a[x][y] =number;????printf("ni hao ma shi %d,ni zai di %d pai di %d lie",number,x,y);??break;
?case '2':??count=0;??printf("please input your number\n");??scanf("%d",&number);?????for(x=0; x<8; x++)??{???for(y=0; y<8; y++)???{????if(a[x][y] ==number)????{?????a[x][y] =0;?????count++;
????}???}??}??if(count !=1)??{???printf("you got a wrong number");??}??else??{???printf("ok");??}??break;
?case '3':??printf("shu ru nin de hang lie hao\n");??scanf("%d %d",&x,&y);??printf("nin de xue hao shi %d",a[x][y]);??break;
?case '4':??printf("please input your number\n");??scanf("%d",&number);????for(x=0; x<8; x++)??{???for(y=0; y<8; y++)???{????if(a[x][y] ==number)????{?????printf("nin zai di %d hang di %d lie",x,y);????}???}??}??break;
??}
goto loop;}