现在写好了,也调试了,自我感觉很好,觉得可以移植到真电梯上去了哦.哈哈.
为了简单,分配了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(power==ON) {
printf("\n\n\nFloor");
for(i=1;i<10;i++)
printf("\n %d",i);
printf("\nPress floor number or q to shut down power :");