@彭志杰 你发的计时器程序我把它改造了一下,你来试试!
按任意字母键就能结束响铃
#include <bits/stdc++.h>
#include <windows.h>
#include <stdlib.h>
#include <conio.h>
#include <winuser.h>
#include <winsock.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, timing starts\n";
Sleep(2000);
system("cls");
cout << a << ":" << b << ":" << c << "\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 << ":" << b << ":" << c << "\n";
Sleep(1000);
system("cls");
}
system("cls");
while(!GetAsyncKeyState('A')&&!GetAsyncKeyState('B')&&!GetAsyncKeyState('C')&&!GetAsyncKeyState('D')&&!GetAsyncKeyState('E')&&!GetAsyncKeyState('F')&&!GetAsyncKeyState('G')&&!GetAsyncKeyState('H')&&!GetAsyncKeyState('I')&&!GetAsyncKeyState('J')&&!GetAsyncKeyState('K')&&!GetAsyncKeyState('L')&&!GetAsyncKeyState('M')&&!GetAsyncKeyState('N')&&!GetAsyncKeyState('O')&&!GetAsyncKeyState('P')&&!GetAsyncKeyState('Q')&&!GetAsyncKeyState('R')&&!GetAsyncKeyState('S')&&!GetAsyncKeyState('T')&&!GetAsyncKeyState('U')&&!GetAsyncKeyState('V')&&!GetAsyncKeyState('W')&&!GetAsyncKeyState('X')&&!GetAsyncKeyState('Y')&&!GetAsyncKeyState('Z')){
system("cls");
cout << "Timing ends!";
cout << char(7);
Sleep(1000);
}cout << "Timing ends!";
return 0;
}
#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;
}