#include <ctime>
#include <bits/stdc++.h>
#define Swap(a,b){ int temp = a; a = b; b = temp;}
using namespace std;
int data[]={0,1,2,3,4,5,6,7,8,9},num = 0;
void Perm(int begin,int end)
{
if(begin == end)
{
num++;
}
else
{
for (int i = begin;i <= end; i++)
{
Swap(data[i],data[begin]);
Perm(begin+1,end);
Swap(data[i],data[begin]);
}
}
return ;
}
int main()
{
clock_t start,end;
start = clock();//开始
Perm(0,9); cout<<num<<endl;
end = clock();//结束
cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;//计算
}
测试代码运行时间
最新推荐文章于 2023-11-15 18:49:47 发布