Contents

Develop
2003.04.23 09:50

[c++] p.58 연습문제 2번

Views 16356 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
#include<iostream.h>
#include<time.h>
#include<string.h>

class stopwatch{
        clock_t c_start, c_end, st, k;
    public :
        stopwatch();
        ~stopwatch();
        start();
        stop(int i);
        show();
};

stopwatch::stopwatch(){
}

stopwatch::~stopwatch(){
        c_end = clock();
        cout << "Bye~ : " << (int)( (c_end - c_start)/CLK_TCK ) << " secn";
}

stopwatch::show(){
        c_end = clock();
        cout << "Show time : " << (int)( (c_end - c_start)/CLK_TCK ) << " secn";
}

stopwatch::start(){
        c_start = clock();
}

stopwatch::stop(int i){
        if(i==0){
                k = clock();
        }else if(i==1){
                st = clock();
                st = st - k;
                c_start = c_start + st;
        }
}

int main(){
        char com[10];
        stopwatch ob;

        cout << "Command: start, stop, exit n";

        while(1){
                cin >> com;
                if(!strcmp(com, "start")) ob.start();
                if(!strcmp(com, "stop")){
                        ob.stop(0);
                        cin >> com;
                        ob.stop(1);
                }if(!strcmp(com, "show")) ob.show();
                if(!strcmp(com, "exit")) return 0;
        }

?

List of Articles
No. Category Subject Author Date Views
1017 Develop [html] 캐쉬된 웹페이지 사용하지 않도록 하는 방법 hooni 2003.04.23 13073
1016 Develop [js] 키보드 아스키코드(ASCII) 코드보기 hooni 2003.04.23 32511
1015 Develop [js] 이벤트 핸들러(Event Handlers) hooni 2003.04.23 6758
1014 Develop [js] 사라지는 브라우저 hooni 2003.04.23 6881
1013 Develop [c] OpenGL 마우스 이벤트 hooni 2003.04.23 8757
1012 Develop [js] 점점 커지는 새창.. hooni 2003.04.23 7024
1011 Develop [c][java] 소켓 프로그래밍(채팅 서버 C, 클라이언트 Java) file hooni 2003.04.23 7032
1010 Develop [c] 신기한 atoi함수(www.game79.net) hooni 2003.04.23 7292
1009 Develop [c] OpenGL 색 입방체의 회전(입체) hooni 2003.04.23 7899
1008 Develop [php] 마시마로 캐릭터 방명록 file hooni 2003.04.23 8277
1007 Develop [c] 시간 계산 하는 프로그램 소스코드 file hooni 2003.04.23 6776
1006 Develop [linux] 프로세스 관련 시스템콜 hooni 2003.04.23 7876
Board Pagination Prev 1 ... 9 10 11 12 13 14 15 16 17 18 ... 98 Next
/ 98