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
1141 Develop [php] 3 Ways to Detect Mobile or Desktop in PHP file hooni 2020.01.28 3727
1140 Develop 자주 쓰는 Docker 명령어 alias hooni 2020.01.10 269689
1139 Develop [python][django] request.cookie 읽어오기 ㅋㅋㅋ (쓰기) hooni 2019.12.06 1694
1138 System/OS SSH Passwordless Login Using SSH Keygen in 5 Easy Steps file hooni 2019.11.22 1395
1137 System/OS [virtualbox] VirtualBox에 Ubuntu 설치하기 file hooni 2019.11.22 914
1136 Database [mysql] MySQL 데이터베이스 추가 및 사용자 추가 hooni 2019.11.22 670
1135 Database [oracle] Oracle 사용자 추가 절차 hooni 2019.11.22 623
1134 Database [mysql] MySQL 백업 및 복구 hooni 2019.11.22 825
1133 Database [mysql] MySql DB/테이블 사이즈 확인을 위한 쿼리 hooni 2019.11.22 664
1132 Database SQL JOIN 정리 (Inner Join & Outer Join) file hooni 2019.11.22 1840
1131 Develop [python] 파라미터 앞에 *, ** 의 의미? (*args, **kwargs) hooni 2019.11.22 1557
1130 Develop 링크들 보고 지울 내용 secret hooni 2019.11.21 0
1129 Develop [Javascript][Ajax] 자바스크립트 강의 산출물 file hooni 2019.10.05 707
1128 Develop [ios] Locale Identifiers file hooni 2018.11.29 1632
1127 Develop [ios] Swift 4 Dictionary 사용하기 file hooni 2018.11.29 2031
1126 Develop [ios] Swift 4 Singleton inheritance hooni 2018.10.31 1597
Board Pagination Prev 1 2 3 4 5 ... 74 Next
/ 74