座位分配系统详解.docVIP

  • 16
  • 0
  • 约5.9千字
  • 约 9页
  • 2016-12-19 发布于重庆
  • 举报
#includestdio.h #includetime.h #includestdlib.h #includestring.h #define ID_LEN 9 /*定义考号的长度,这样做的好处就是每个学校的考号位数可能不同,这样增加了程序可移植性*/ #define MAXLINE 8 #define MAXROW 8 struct student{ char name[20]; /*姓名最多容纳20字符的字符串*/ char id[ID_LEN]; /*考号最多容纳8个字符的字符串*/ int flag; /*标记该座位是否有人*/ }seat[8][8]; /*定义一个8*8的二维数组,去装每个位置的考生信息*/ void Initialization() {/*初始化5个座位*/ int x,y,i; /*xy分别代表x行和y列*/ char tname[20],tid[8]; for(i=0;i5;i++){ /*随机产生座位*/ srand((unsigned)time(NULL)); x=rand()%8+1; y=rand()%8+1; while(seat[x][y].flag!=0) /*当flag不为0时说明位置有人了,所以重新随机分配*/ {

文档评论(0)

1亿VIP精品文档

相关文档