首先是最直接的方法:
- #include <stdio.h>
- #include <stdlib.h>
- #include <windows.h>
- int main()
- {
- int i;
- printf("2:00\n");
- Sleep(1000);
- system("cls");
- i = 59;
- while(i >= 10){
- printf("1:%d", i);
- Sleep(1000);
- system("cls");
- i = i - 1;
- }
- while(i >= 0){
- printf("1:0%d", i);
- Sleep(1000);
- system("cls");
- i = i - 1;
- }
- i = 59;
- while(i >= 10){
- printf("0:%d", i);
- Sleep(1000);
- system("cls");
- i = i - 1;
- }
- while(i >= 0){
- printf("0:0%d", i);
- Sleep(1000);
- system("cls");
- i = i - 1;
- }
-
- system("pause");
- return 0;
- }
复制代码
先打印2:00,然后分成4段处理,1:59 - 1:10, 1:09 - 1:00, 0:59 - 0:10, 0:09 - 0:00
打印时间 - 暂停1秒 - 清屏 - 打印下一个时间 |