简易秒表
代码
// Author : Weihao Long
// Created : 2018/03/15
#include <Windows.h>
#include <bits/stdc++.h>
using namespace std;
class Stopwatch {
public:
Stopwatch(int h = 0, int m = 0, int s = 0) :hour(h), minute(m), second(s) {}
void run() {
while (true) {
show();
Sleep(1000);
tick();
}
}
private:
int hour, minute, second;
void show() {
printf("\r");
printf("%02d:%02d:%02d", hour, minute, second);
}
void tick() {
second += 1;
if (second == 60) {
second = 0;
minute += 1;
if (minute == 60) {
minute = 0;
hour += 1;
}
if (hour == 24) {
hour = 0;
}
}
}
};
int main() {
Stopwatch c;
c.run();
return 0;
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。