洛谷 P2525 Uim的情人节礼物·其之壱

在这里插入图片描述
思路:利用STL函数

#include<bits/stdc++.h>
using namespace std;
const int MAXSIZE = 10;
int main()
{
	int n;
	int a[MAXSIZE];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	if (prev_permutation(a, a + n))//prev_permutation函数可以制造前一个排列,如果已经为第一个,则返回false
		for (int i = 0; i < n; i++)
			cout << a[i] << " ";
	else cout << "ERROR";
	return 0;
}
发布了99 篇原创文章 · 获赞 44 · 访问量 5534

猜你喜欢

转载自blog.csdn.net/weixin_44413191/article/details/102549173