編程計時
發布時間: 2024-07-30 13:53:36
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLK_TCK ;
while (clock() < endwait) {}
}
void main(){
int t,m,s;
printf("input counterdown time in seconds\n");
scanf("%d",&t);
printf("\n===================\n");
while(1)
{
wait ( 1 );
t--;
if (t==0) break;
s = t % 60;
m = t / 60;
printf("\r\t%02d:%02d",m,s);
}
exit(0);
};
熱點內容