You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
486 B

2 years ago
#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;
}