Cod sursa(job #2979060)

Utilizator stefanrotaruRotaru Stefan-Florin stefanrotaru Data 14 februarie 2023 19:08:01
Problema Generare de permutari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.37 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("permutari.in");
ofstream g("permutari.out");

int n, a[] = {1, 2, 3, 4, 5, 6, 7, 8};

int main()
{
    f >> n;

    do {
        for (int i = 0; i < n; ++i) {
            g << a[i] << ' ';
        }

        g << "\n";
    } while (next_permutation(a, a + n));

    g.close();

    return 0;
}