Cod sursa(job #2881231)

Utilizator QwertyDvorakQwerty Dvorak QwertyDvorak Data 30 martie 2022 12:52:54
Problema Generare de permutari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.53 kb
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define dbg(x) cout << #x <<": " << x << "\n";
#define sz(x) ((int)x.size())

using ll = long long;

const string fn = "permutari";
ifstream fin(fn + ".in");
ofstream fout(fn + ".out");
int n;

int main(){

    fin >> n;
    vector<int> v;
    for (int i = 1; i <= n; ++i)
        v.pb(i);
    do{
        for(auto i : v)
            fout << i << " ";
        fout << '\n';

    } while (next_permutation(v.begin(), v.end()));

        return 0;
}