求助大佬,蒟蒻不知道哪里有问题,测试了很多次
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
int a[10] = { 0 };
for (int i = 1; i <= n; i++) {
a[i] = i;
}
do {
for (int i = 1; i <= n; i++) {
printf("%5d", a[i]);
}
cout << endl;
} while (next_permutation(a+1, a + n + 1));
return 0;
}