65,211
社区成员
发帖
与我相关
我的任务
分享#include <stdio.h>
#include <time.h>
void wait ( int seconds )//输入要等待的秒数,你自己可以转换一下。
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}
int main ()
{
int n;
printf ("Starting countdown...\n");
for (n=10; n>0; n--)//这里是测试用的,你实际用的时候,不需要这个循环的。
{
printf ("%d\n",n);
wait (1);//这里是每次等一秒钟
}
printf ("FIRE!!!\n");
return 0;
}
while(true)
{
if(mytime==settime)
break;
}time_t temp= time(NULL);
struct tm *blocal = localtime(&temp);
cout<<"time is "<<asctime(blocal)<<endl;
cout<<blocal->tm_year+1900 <<"年"<<blocal->tm_mon+1<<"月"<<blocal->tm_mday<<"日"<<endl;得到当前的年月日