Add tags

Add tags to the following comment
適当に拡張性を考えて書いてみた。
 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;
}

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...