zl程序教程

您现在的位置是:首页 >  IT要闻

当前栏目

代码计算程序运行的时间

2023-02-18 16:34:31 时间

代码计算程序运行的时间

为了计算程序运行的时间

#include<bits/stdc++.h>
using namespace std;
#include<ctime>

void func1(){
    int a[]={1,2,3};
    do{
        for (int i = 0; i <= 2; i++)
        {
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }while(next_permutation(a,a+3));
}


int main(){
    clock_t start,end;
    start=clock();
    func1();
    end=clock();
    cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;


}