Cod sursa(job #947451)

Utilizator costyrazvyTudor Costin Razvan costyrazvy Data 7 mai 2013 15:46:12
Problema Generare de permutari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.48 kb
#include <fstream>
#define pb push_back
#include <algorithm>
#include <vector>
using namespace std;
vector <int> v;
int i,n;
int main()
{
    ifstream f("permutari.in");
    ofstream g("permutari.out");
    f>>n;
    for (i=1;i<=n;i++) v.pb(i);
    for (i=0;i<n;i++)
    {  g<<v[i]<<" ";
    }
    g<<'\n';
    while (next_permutation(v.begin(),v.end()))
    {
        for (i=0;i<n;i++) g<<v[i]<<" ";
        g<<'\n';
    }
    f.close();
    g.close();
    return 0;
}