こう。 #6351(2008/05/27 03:11 GMT) [ C ] Rating0/0=0.00
適当に拡張性を考えて書いてみた。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#include <stdio.h> #include <conio.h> #include <time.h> #define STATE_RUN 0 #define STATE_WAIT 1 #define STATE_QUIT 2 int main(){ time_t now,last; int c; int state=STATE_RUN; last=time(NULL); do{ if(kbhit()){ c=getch(); switch(c){ case 'q': state=STATE_QUIT; break; case 'p': if(state==STATE_RUN){ state=STATE_WAIT; }else{ state=STATE_RUN; } } } switch(state){ case STATE_RUN: now=time(NULL); if(last-now!=0){ last=now; printf("a"); fflush(stdout); } } }while(state!=STATE_QUIT); return 0; }
Rating0/0=0.00-0+
[ reply ]
こう。 #6351() [ C ] Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]