Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n,v[999999];
- char x[999999];
- int modul(int dif){
- if(dif < 0)
- {
- dif = -dif;
- return dif;
- }
- return dif;
- }
- void print(){
- for(int i = 1; i<=n; i++)
- {
- x[i] = 97 + v[i];
- cout << x[i];
- }
- cout << endl;
- }
- void bak(int k){
- for(int i = 0; i<=n/2; i++){
- v[k] = i;
- if(v[1] == 0 && (k == 1 || modul(v[k]- v[k-1])== 1))
- if(k == n){
- if(v[n] == 0) print();
- }
- else
- bak(k+1);
- }
- }
- int main(){
- cin >> n;
- bak(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement