我的一个倒计时程序,求指教
#include <stdio.h>#include <windows.h>
main()
{
int total_time, hour, minute, second;
printf("please set time(hour,minute,second) :\n");
scanf("%d%d%d",&hour, &minute, &second);
printf("time is %d:%d:%d\n",hour, minute, second);
total_time = hour * 3600 + minute * 60 + second;
printf("total time is:%d\n",total_time);
while(total_time != 0) {
hour = total_time / 3600;
minute = (total_time - hour * 3600) / 60;
second = (total_time - hour * 3600) % 60;
total_time --;
Sleep(1000);
system("cls");
printf("time is %d:%d:%d\n",hour, minute, second);
}
/*Sleep(1000);
system("cls");
printf("time is over! BOOM!!!!\n");*/
return 0;
}
结果显示老是还剩一秒“0:0:1”,而不是我想要的“0:0:0”!