啊哈磊_编程从这里起步
标题:
倒计时
[打印本页]
作者:
幻想hacker,,,
时间:
2018-8-9 23:24
标题:
倒计时
怎么写一个例如两分钟的倒计时
如: 2:00 1:59 1:58........0:02 0:01 0:00
作者:
孤笙
时间:
2018-8-10 14:20
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
int m = 120;
system("cls");
while (m >= 0)
{
printf("\r%d:%.2d", m/60, m%60);
m = m - 1;
Sleep(1000);
}
system("pause");
return 0;
}
作者:
suifengtec
时间:
2018-8-10 21:20
#include<stdio.h>
#include<stdlib.h>
#ifdef _WIN32
#include<windows.h>
#endif
/*
2分钟倒计时,每秒带声音
*/
int main(void)
{
//120s=2m
int i = 120;
for(;i>=0;--i){
printf("%d\n",i);
#ifdef _WIN32
Beep(800,900);
Sleep(1000);
#else
usleep(1000);
#endif
system("cls");
}
return 0;
}
复制代码
作者:
鼬神
时间:
2018-8-13 12:24
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
int m = 120;
system("cls");
while (m >= 0)
{
printf("\r%d:%.2d", m/60, m%60);
m = m - 1;
Sleep(1000);
}
system("pause");
return 0;
}
作者:
赤色之瞳
时间:
2018-8-15 08:51
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
int a,b;
a=2;
b=00;
printf("%d:%d",a,b);
a=1;
while(a=0 && b=0)
{
if(a=1)
{
b=59;
}
system("cls");
printf("%d:%d",a,b);
Sleep(1000);
b=b-1;
if(b=0)
{
a=0;
b=59;
}
}
system("pause");
return 0;
我自己做的,试试吧
欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/)
Powered by Discuz! X3.2