too short?????
查看原帖
too short?????
814343
bc2_cryeggy楼主2023/2/1 20:44

代码:

#include<bits/stdc++.h>
using namespace std;
#define qwq ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

int main()
{
	qwq;
	int n, a[10] = {0}, res = 1;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		a[i] = n - i + 1, res *= i;
	}
//	for (int i = 1; i <= n; i++)
//	{
//		printf("%5d", a[i]);
//	}
//	cout << endl;
	for (int i = 1; i <= res - 1; i++)
	{
		next_permutation(a + 1, a + n + 1);
		for (int j = 1; j <= n; j++)
		{
			printf("%5d", a[j]);
		}
		cout << endl;
	}
	return 0;
}
2023/2/1 20:44
加载中...