⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 电梯.txt

📁 一个用c编的电梯模拟小程序
💻 TXT
字号:
#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 :"); 

if( now.ti_hour>=8||(now.ti_hour<=23&&now.ti_min<59)) 
power=ON; 
else 
power=OFF; 

key=bioskey(0); 
key=key&0x00ff; 


system("cls"); 
if(key=='0'){ 

power=OFF; 
printf("\n\n Lift Power off"); 
sleep(1); 
break; 
} 
if(key>oldkey) 
printf(" %c Go up!...",24); 
if(key<oldkey) 
printf(" %c Go down!...",25); 
if(key==oldkey) 
printf(" %c ok you are here",22); 
sleep(2); 
system("cls"); 
printf("\n\n "); 

switch(key){ 
case '1': 
if(key==oldkey) 
printf(" %c ok you are here",22); 
else if(key>oldkey) 

printf("%c Go up!...stop in %c floor.",24,key); 
else 
printf("%c Go down!...stop in %c floor.",25,key); 
oldkey=key; 
break; 
case '2': 
if(key==oldkey) 
printf(" %c ok you are here",22); 
else if(key>oldkey) 

printf("%c Go up!...stop in %c floor.",24,key); 
else 
printf("%c Go down!...stop in %c floor.",25,key); 
oldkey=key; 
break; 
case '3': 
if(key==oldkey) 
printf(" %c ok you are here",22); 
else if(key>oldkey) 

printf("%c Go up!...stop in %c floor.",24,key); 
else 
printf("%c Go down!...stop in %c floor.",25,key); 
oldkey=key; 
break; 
case '4': 
if(key==oldkey) 
printf(" %c ok you are here",22); 
else if(key>oldkey) 

printf("%c Go up!...stop in %c floor.",24,key); 
else 
printf("%c Go down!...stop in %c floor.",25,key); 
oldkey=key; 
break; 
case '5': 
if(key==oldkey) 
printf(" %c ok you are here",22); 
else if(key>oldkey) 

printf("%c Go up!...stop in %c floor.",24,key); 
else 
printf("%c Go down!...stop in %c floor.",25,key); 
oldkey=key; 
break; 
case '6': 
if(key==oldkey) 
printf(" %c ok you are here",22); 
else if(key>oldkey) 

printf("%c Go up!...stop in %c floor.",24,key); 
else 
printf("%c Go down!...stop in %c floor.",25,key); 
oldkey=key; 
break; 
case '7': 
if(key==oldkey) 
printf(" %c ok you are here",22); 
else if(key>oldkey) 

printf("%c Go up!...stop in %c floor.",24,key); 
else 
printf("%c Go down!...stop in %c floor.",25,key); 
oldkey=key; 
break; 
case '8': 
if(key==oldkey) 
printf(" %c ok you are here",22); 
else if(key>oldkey) 

printf("%c Go up!...stop in %c floor.",24,key); 
else 
printf("%c Go down!...stop in %c floor.",25,key); 
oldkey=key; 
break; 
case '9': 
if(key==oldkey) 
printf(" %c ok you are here",22); 
else if(key>oldkey) 

printf("%c Go up!...stop in %c floor.",24,key); 
else 
printf("%c Go down!...stop in %c floor.",25,key); 
oldkey=key; 
break; 



} 
} 
getch(); 
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -