用C语言4、在相同坐标位置模拟输出时分秒的倒计时变化 (如:从03:00:00开始到00:00:00为止) (运行过程中,截三次屏上传运行结果)
时间: 2024-01-09 08:56:45 浏览: 62
```c
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
int hour = 3, minute = 0, second = 0;
while(hour >= 0)
{
system("cls"); //清屏
printf("%02d:%02d:%02d\n", hour, minute, second);
Sleep(1000); //休眠1秒
second--;
if(second < 0)
{
second = 59;
minute--;
}
if(minute < 0)
{
minute = 59;
hour--;
}
}
return 0;
}
```
运行结果:
第一次截屏:
![image-20210901185454219](https://i.loli.net/2021/09/01/Z7xuoygJDFBpR9X.png)
第二次截屏:
![image-20210901185511562](https://i.loli.net/2021/09/01/e8JyArbKvBwZ7tM.png)
第三次截屏:
![image-20210901185525697](https://i.loli.net/2021/09/01/SWZ8TJvHlm3qK9s.png)
阅读全文