c++统计for运行时间

 1  #include<bits/stdc++.h>
 2    using namespace std;
 3    int main(){
 4       int i,k,n = 1e9;
 5       clock_t start,end;
 6       start = clock();
 7       for(i=0;i<n;i++)k++;
 8       end=clock();
 9       cout<<(double)(end -start)/CLOCKS_PER_SEC<<endl;
10       return 0;
11   } 

 

posted @ 2021-08-03 22:44  guoyuxin3  阅读(107)  评论(0)    收藏  举报