Cod sursa(job #3312706)
| Utilizator | Data | 29 septembrie 2025 16:42:15 | |
|---|---|---|---|
| Problema | Generare de permutari | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifndef LOCAL
freopen("permutari.in", "r", stdin);
freopen("permutari.out", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
vector<int> P(N);
iota(P.begin(), P.end(), 1);
do {
for (int i = 0; i < N; ++i) {
if (i) {
cout << " ";
}
cout << P[i];
}
cout << endl;
} while (next_permutation(P.begin(), P.end()));
return 0;
}