请尝试编写一个2分钟的倒计时.形如:2:00 1:59……用C语言啊~~~不要C++
发布网友
发布时间:2022-05-06 10:34
我来回答
共3个回答
热心网友
时间:2023-10-09 04:50
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
int a,b,c;
a=120;
system("color 0a");
while(a>=0)
{
system("cls");
b=a/60;
c=a%60;
printf("%d:%.2d",b,c);
a=a-1;
Sleep(1000);
}
Sleep(50000);
return 0;
热心网友
时间:2023-10-09 04:50
#include <TIME.H>#include <windows.H>
#include <process.h>
#include <stdio.H>
int main()
{
int iNeedTiem = 120;
//cin>>iNeedTiem;
int iMin = 0; int iSec = 0;
while (1)
{
iMin = iNeedTiem/60;
iSec = iNeedTiem - iMin*60;
printf("%d:%d",iMin,iSec); iNeedTiem--;
Sleep(1000);
system("cls");
if (iMin == 0 && iSec == 0) {
break;
}
}
return 0;}
热心网友
时间:2023-10-09 04:51
/////////////////////////////////////////
// C-Free 4.1
// MinGW 3.4.5
// veket的小号
/////////////////////////////////////////
#include <stdio.h>
#include <windows.h>
int main()
{
int min = 0;
int sec = 5;
for(;;)
{
printf("%d:", min);
sec>9?printf("%d", sec):printf("0%d", sec);
Sleep(1000);
if(!(min+sec))break;
printf("\b\b\b\b");
sec--;
if(sec<0)
{
sec = 59;
min--;
}
}
return 0;
}