问题标题: 一个需要测试的计时器

2
1
已解决
彭志杰
彭志杰
中级天翼
中级天翼
#include <bits/stdc++.h>
#include <windows.h>
#include <stdlib.h>
using namespace std;
int a, b, c; // hours, minutes, seconds
int main() {
    cout << "Please input the timekeeping, do not enter decimals:\n";
    cout << "Hours(The input number must smaller than 24):";
    cin >> a;
    cout << "\nMinutes(The input number must smaller than 60):";
    cin >> b;
    cout << "\nSeconds(The input number must smaller than 60):";
    cin >> c;
    cout << "OK now, iming starts\n";
    system("cls");
    cout << a << "hours  " << b << "minutes  " << c << "seconds\n";
    Sleep(1000);
    system("cls");
    while(1) {
        if(!a&&!b&&!c) break;
        if(!c&&b) c=60, b--;
        else if(!b&&a&&!c) c=60, b=59, a--; 
        c--;
        cout << a << "hours  " << b << "minutes  " << c << "seconds\n";
        Sleep(1000);
        system("cls");
    }
    system("cls");
    cout << char(7) << "Timing ends!";
    return 0;
}

这是一个计时器,自测没问题,希望大家能使用测试一下

使用&亮点说明:

1. 可以显示剩余时间

2. 倒计时结束时有提示音


0
已采纳
方钰涵
方钰涵
新手守护
新手守护

2.0版本写好后,其实我在想着退出2.0.5版本

区别就是1.0和2.0版本显示的是1位时间(如:0:1:3),2.0.5版本可以显示2位时间(如:00:01:03)。

有空一起来编一下~

0
彭志杰
彭志杰
中级天翼
中级天翼

之所以是英文提示词是因为我的dev-c++用中文输出会变成UTF-8码。。。

0
0
0
我要回答