20 lines
486 B
C++
20 lines
486 B
C++
#include <bits/stdc++.h>
|
||
|
||
using namespace std;
|
||
|
||
int main() {
|
||
int n, i;
|
||
cin >> n;
|
||
int a[n];
|
||
//输入数据
|
||
for (i = 0; i < n; i++)
|
||
cin >> a[i];
|
||
//而STL中有两个函数,分别是 prev_permutation 和 next_permutation.
|
||
//它们是现成的求上一个和下一个字典序的序列的。
|
||
prev_permutation(a, a + n);//求上一个全排列
|
||
|
||
//输出
|
||
for (i = 0; i < n; i++)
|
||
cout << a[i] << " ";
|
||
return 0;
|
||
} |