平时看你们发的代码一行一个颜色,今天试上,如何弄的呀
平时看你们发的代码一行一个颜色,今天试下,怎么弄的呀
------解决方案--------------------
插入源代码
- C/C++ code
[color=#00FF00] #include <ctime> #include "clock.h" /*-------------------- 作用:设置休息时间 参数:时分秒(整形) 返回值:无 ---------------------*/ void Clock::setTime(int ahour, int amin, int asec) { m_ihour = ahour; m_imin = amin; m_isec = asec; m_lsetsec = ahour * 60 * 60 + amin * 60 + asec; } /*-------------------- 作用:用光从现在到设置的时刻之间的所有时间 参数:无 返回值:无 ---------------------*/ void Clock::runOutTime(void) { time_t now; struct tm *fmt; time(&now); fmt = localtime(&now); //计算现在的时间秒数 long nowsec = fmt->tm_hour * 60 * 60 + fmt->tm_min * 60 + fmt->tm_sec; //计算从现在到设置的时间之间的秒数 long difsec = m_lsetsec - nowsec; //一直进行此循环,直到到达设置的时间为止 while(time(0) - now < difsec) ; } [/color]
------解决方案--------------------
插入源代码