#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    int arr[n];
    for (int i=0;i<n;i++) {
        arr[i] = i+1;
    }
    do{
        for (int i=0;i<n;i++) {
            cout << arr[i] << " ";
        }
        cout << "\n";
    }while(next_permutation(arr,arr+n));
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: