南京交通设施有限公司 mytime类: #include"time.h" class mytime { private: static int min;//分钟 static int sec;//秒 public: static sleep(int seconds) { clock_t wait=(clock_t)seconds*CLOCKS_PER_SEC; clock_t goal; goal=wait+clock(); while(goal>clock()); } static int get_minte() { int n=clock()/CLOCKS_PER_SEC; return n/60; } static int get_second() { int n=clock()/CLOCKS_PER_SEC; return n%60; } }; 调用此类~ #include "stdio.h" #include "mytime.h" #include "stdlib.h" void main() { //mytime printf("当前时间:%d:%d/n",mytime::get_minte(),mytime::get_second()); mytime::sleep(5); printf("当前时间:%d:%d",mytime::get_minte(),mytime::get_second()); //mytime.sleep(5); mytime::sleep(60); printf("当前时间:%d:%d",mytime::get_minte(),mytime::get_second()); } 更多内容请访问:围观IT