#include<stdio.h> #include<time.h> #include<windows.h> int main() { printf("start...\n"); int start = clock(); int end ,time ,i = 0; while(1) { //system("cls"); printf("%d\r",i++); Sleep(1000); end = clock(); time = (end - start)/CLOCKS_PER_SEC; if(time >= 5) { printf("%d\n",i); break; } } printf("end...\n"); return 0; }利用clock()写的简单计时器,依次输出1到5,到达5秒自动退出
C语音简单计时器
最新推荐文章于 2023-06-05 06:45:00 发布