新手求助!我这个枚举法写的有关红绿灯程序是哪里出了问题?求指导
程序代码:
#include<stdio.h> enum TRAFFIC_LED{RED,GREEN,YELLOW}; void wait1sec(void); void main() { enum TRAFFIC_LED led; char display[3][4]={"R","G","Y"}; int timers; led=RED; while(1) { if(led==RED) { printf("%c",'\r'); printf("%s",display[led]); timers=30; do{ printf("%3d",timers); timers--; printf("%c%c%c",'\b','\b','\b'); wait1sec(); }while(timers>0); led=GREEN; } else if(led==GREEN) { printf("%c",'\r'); printf("%s",display[led]); timers=30; do{ printf("%3d",timers); timers--; printf("%c%c%c",'\b','\b','\b'); wait1sec(); }while(timers>0); led=YELLOW; } else { printf("%c",'\r'); printf("%s",display[led]); timers=5; do{ printf("%3d",timers); timers--; printf("%c%c%c",'\b','\b','\b'); wait1sec(); }while(timers>0); led=RED; } } void wait1sec(void) { int n; n=1; while(n<10000000) n++; }