关于最近阅读猴子排序后我突发灵感,写了一个全排列排序,代码如下,如果有了,当我没说:
#include<bits/stdc++.h>
#define sjh0626s
#define code
using namespace std;
int a[5]={5,4,3,2,1},b[5]={5,4,3,2,1};
int main(){
next_permutation(b,b+5);
do{
if(is_sorted(a,a+5)){
for(int i=0;i<=4;i++){
cout<<a[i]<<" ";
}
return 0;
}
else if(is_sorted(b,b+5)){
for(int i=0;i<=4;i++){
cout<<b[i]<<" ";
}
return 0;
}
}while(next_permutation(b,b+5)||prev_permutation(a,a+5));
}