'commit'
This commit is contained in:
14
C++专题课程/全排列/STL函数实现全排列.cpp
Normal file
14
C++专题课程/全排列/STL函数实现全排列.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main() {
|
||||
//注意:这个数组的数字要先排好顺序,由小到大,否则只输出比现在大的全排列!
|
||||
int num[5]= {3,1,2,4,5};
|
||||
//快速排序
|
||||
sort(num, num+5);
|
||||
//输出全排列
|
||||
do {
|
||||
cout<<num[0]<<" "<<num[1]<<" "<<num[2]<<" "<<num[3]<<" "<<num[4]<<endl;
|
||||
} while(next_permutation(num,num+5));
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user