Develop
2003.04.23 09:50
[c++] p.58 연습문제 2번
조회 수 16347 댓글 0
#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;
}
}
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
733 | Develop | [js] URL 파싱하기 (jQuery 안쓰고) | hooni | 2017.12.14 | 1421 |
732 | Develop | [php] 한글 문자열 자르기 (utf-8) | hooni | 2015.11.10 | 1429 |
731 | Develop | [android] 간단한 SQLIite 예제 | hooni | 2017.06.14 | 1437 |
730 | Develop | [ios] How to set up clang formatter | hooni | 2015.09.17 | 1457 |
729 | Develop | [ios] Swift 4 String, Date, DateFormatter 예제 | hooni | 2018.10.18 | 1495 |
728 | Develop | [swift] popToRoot 모달뷰, 네비게이션컨트롤러 한꺼번에 닫기 | hooni | 2021.01.29 | 1528 |
727 | Develop | What is difference between Get, Post, Put and Delete? | hooni | 2018.02.28 | 1554 |
726 | Develop | How to Test SMTP AUTH using Telnet | hooni | 2018.04.05 | 1564 |
725 | Develop | [android] 레이아웃 사이즈 변경 (동적; programmatically) | hooni | 2016.11.07 | 1592 |
724 | Develop | [ios] binary를 C코드로 변환 | hooni | 2015.01.03 | 1629 |
723 | Develop | [ios] 스크린 캡쳐 (전원버튼 + 홈버튼) 호출 알아내기 | hooni | 2014.11.19 | 1640 |
722 | Develop | [python] 파라미터 앞에 *, ** 의 의미? (*args, **kwargs) | hooni | 2019.11.22 | 1666 |