Cod sursa(job #2274939)

Utilizator OctavianVasileVasileOctavian OctavianVasile Data 2 noiembrie 2018 17:49:07
Problema Generare de permutari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.5 kb
#include<bits/stdc++.h>
using namespace std;
ifstream fin ("permutari.in");
ofstream fout ("permutari.out");
int n, v [200], f [200];
void print (){
    for (int i = 1; i <= n; i ++)fout << v [i] << " ";
    fout << '\n';
}
void func (int poz){
    if (poz == n + 1)print ();
    for (int i = 1; i <= n; i ++){
        if (f [i] == 0){
            f [i] = 1;
            v [poz] = i;
            func (poz + 1);
            f [i] = 0;
        }
    }
}
int main (){
	fin >> n;
	func (1);
}