表示如果想要写sleep函数的话,完全可以自己手动写一个啊,不需要头文件windows.h,而是使用头文件ctime,如下:
- #include<ctime>
- #include<cstdio>
- using namespace std;
- void sleep(double time)
- {
- clock_t s,e;
- double x;
- s=clock();
- while(1)
- {
- e=clock();
- x=(double)(e-s)/CLOCKS_PER_SEC;
- if(x>=time) return;
- }
- }
- int main()
- {
- sleep(2);
- printf("hello");
- sleep(2);
- printf("_");
- sleep(2);
- printf("world");
- sleep(2);
- return 0;
- }
复制代码 |