|
本帖最后由 981013 于 2014-8-13 10:01 编辑
可以用单个变量(秒)做
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main(int argc, const char * argv[])
{
int sec=120;
while (sec!=0)
{
printf("%02d:%02d\n",sec/60,sec%60);
Sleep(1000);
--sec;
}
return 0;
}
[/mw_shl_code]如果一定要两个变量的话可以:
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main(int argc, const char * argv[])
{
int min=2,sec=0;
printf("%02d:%02d\n",min,sec);
while (min!=0){
--min;
sec+=60;
while (sec!=0)
{
--sec;
printf("%02d:%02d\n",min,sec);
Sleep(1000);
}
}
return 0;
}
[/mw_shl_code]
|
|