Develop
2003.04.23 09:50

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

Views 16296 Votes 0 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
809 Develop [matlab] 정보은닉 스테가노그래피(Steganography) 수업 file hooni 2016.10.03 680
808 Develop [android] Android N requires the IDE to be running with Java 1.8 or later 오류 hooni 2016.08.30 684
807 Develop [ios] 비디오,네트워크,소셜로그인 테스트 file hooni 2017.04.04 684
806 Develop [Javascript][Ajax] 자바스크립트 강의 산출물 file hooni 2019.10.05 699
805 Develop [ios] Crashlytics, Fabfic 설치/설정 hooni 2016.07.21 724
804 Develop 캘리포니아 운전면허 족보 file hooni 2017.06.12 734
803 Develop [ios][swift] 초간단 TableView 샘플 file hooni 2016.06.27 734
802 Develop [ios] 앱에서 설정화면 호출하기 hooni 2015.04.07 743
801 Develop 리팩토링 계획안 file hooni 2017.05.15 746
800 Develop [c] 파일명 또는 특정 패턴을 적용 file hooni 2016.08.03 748
799 Develop [Android Error] The number of method references in a .dex file cannot exceed 64K hooni 2016.11.10 754
798 Develop [linux] CentOS Apache 웹서버에 HTTPS 적용 hooni 2015.10.23 783
797 Develop [io] Apple Watch, Today Extension 앱ID 설정 hooni 2016.04.20 792
796 Develop [c] 기막힌 정렬 코드 ㅋㄷ file hooni 2015.10.13 807
795 Develop [js] e.stopPropagation() VS e.preventDefault () file hooni 2015.04.14 808
794 Develop [android] 초간단 얼럿 (AlertDialog) hooni 2016.10.21 809
Board Pagination Prev 1 2 3 4 5 ... 53 Next
/ 53