Contents

Develop
2003.04.23 09:50

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

Views 16348 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
145 Develop [c++] 인라인 함수 설명과 예제.. file hooni 2013.04.23 6661
144 Develop [c++] 윈도우 프로세스뷰어 분석.. ㅋㅋ file hooni 2013.04.23 8856
143 Develop [c++] 윈도우 API 정복 예제 file hooni 2013.04.23 7632
142 Develop [c++] 웹폼(webform)전송과 http 파일 업로드 샘플 file hooni 2013.04.23 33105
141 Develop [c++] 압축프로그램(Lite Zip) 샘플 file hooni 2013.04.23 8624
140 Develop [c++] 쓰레드(Thread) 객체의 사용 hooni 2013.04.23 8602
139 Develop [c++] 소켓 프로그래밍 관련 링크.. (퍼올려고 올린거) hooni 2013.04.23 7058
138 Develop [c++] 바탕화면 테두리에 자석처럼 붙는 스냅효과.. file hooni 2013.04.23 8923
137 Develop [c++] 문자열 뒤집기(문자열 거꾸로 출력) hooni 2013.04.23 17304
136 Develop [c++] 마방진 소스코드 file hooni 2013.04.23 9567
135 Develop [c++] 링크리스트(linked list) 클래스(스택,큐) file hooni 2003.04.23 9581
134 Develop [c++] 레지스트리 편집하는 부분..ㅡㅡ; file hooni 2013.04.23 8291
Board Pagination Prev 1 ... 54 55 56 57 58 59 60 61 62 63 ... 71 Next
/ 71