#include <stdio.h>
#include <conio.h> //kbhit()/_kbhit()
#include <Windows.h> //Sleep(ms)
int main()
{
int hour = 0, min = 0, sec = 0;
int cnt = 0;
printf("按任意键停止计时\n");
while(!_kbhit()) //任意键退出循环(结束计时)
{
hour = cnt / 3600; //获取计时小时数
min = cnt / 60; //获取计时分钟数
sec = cnt % 60; //获取计时秒数
printf(" %02d:%02d:%02d\r", hour, min, sec);
Sleep(1000); //1s延时
cnt++;
}
printf("\n程序退出\n");
return 0;
}
计算器C++
最新推荐文章于 2024-08-16 14:32:56 发布