求模拟10层的可以运行的电梯控制程序(C/C++)

来源:百度知道 编辑:UC知道 时间:2024/06/05 20:55:25

现在写好了,也调试了,自我感觉很好,觉得可以移植到真电梯上去了哦.哈哈.
为了简单,分配了1到9层.另外也没加入有几人同时按,不过那样也不难,再分配10个每层的变量,随机按.再处理,是先向上还是直接向下.不过那倒真的可以用到真的上了.

#include <stdio.h>
#include <dos.h>
#include <ctype.h>
#define ON 1
#define OFF 0
main(){

int power,i;
char oldkey,key ;
struct date today;
struct time now;
getdate(&today); /*把系统当前日期存入today所指向的date结构中*/
gettime(&now);
gotoxy(25,3);
printf("Today's date is %d-%d-%d\n",today.da_year,today.da_mon,today.da_day);
gotoxy(25,6);
printf("Current time is %02d:%02d:%02d\n",now.ti_hour,now.ti_min,now.ti_sec);

if( now.ti_hour>=8||(now.ti_hour<=23&&now.ti_min<59)){
power=ON;
printf("\n\n\nLift power is on.Lift stop in 1 floor.");

}
else {
power=OFF;
printf("Lift power is off.");
}
oldkey=0;

while(powe