Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int N, fol[26];
- void gen(int lg, int sir[277]) {
- if (lg == N + 1) {
- for (int i = 1; i <= N; ++i)
- cout<<sir[i];
- cout<<"\n";
- return;
- }
- for (int c = 1; c < 1 + N; ++c)
- if (fol[c] == 0) {
- sir[lg] = c;
- fol[c] = 1;
- gen(lg + 1, sir);
- fol[c] = 0;
- }
- return;
- }
- int main()
- {
- cin>>N;
- int s[100];
- gen(1,s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement