Cod sursa(job #2236336)
| Utilizator | Data | 29 august 2018 10:45:04 | |
|---|---|---|---|
| Problema | Generare de permutari | Scor | 80 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.57 kb |
#include <iostream>
#include <algorithm>
#include <fstream>
using namespace std;
ifstream in("permutari.in");
ofstream out("permutari.out");
int main()
{
int n;
in >> n;
int myints[n];
for(int i = 1; i<=n;++i){
myints[i-1] = i;
}
sort(myints, myints+n);
int j = 0;
for(int i = 0; i<n;++i){
out << myints[i] << " ";
}
out << endl;
while(next_permutation(myints, myints+n)){
for(int i = 0; i<n;++i){
out << myints[i] << " ";
}
out << endl;
}
}
