C语言代码翻译

#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);
}

求这段C语言代码的翻译,就是指出每一句语句都具体是什么意思,最好能带个简单的流程图
1
我要的是中文解释。。。因为老师要提问的。。。

#include <stdio.h>
#include <stdlib.h>
#include <time.h> //三个头文件

void wait ( int seconds ) //定义一个具有等待功能的函数
{
int a=0;
clock_t endwait; //clock_t 就是long 型
//通过下面两部实现等待seconds秒的作用
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) //只要时间不为0 不断执行循环
{
wait (1); //执行wait函数 程序等待一秒
t--; //倒计时总秒数每隔一秒自动减一
if(t==0)
break;
s = t % 60; //确定倒计时分钟
m = t / 60; //确定倒计时秒数
printf("\r\t%02d:%02d",m,s);
}
exit(0);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-07-08
编译一扁就行了。

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网