Cod sursa(job #1504973)

Utilizator ilinoiuflaviusIlinoiu Flavius ilinoiuflavius Data 18 octombrie 2015 16:52:33
Problema Generare de permutari Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.36 kb
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;

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

int n,v[10];

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