Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- char myStr[25],ch1,ch2;
- int digit;
- int countA=0, countB=0;
- void think(int index){
- if(index==2*digit) std::cout<<myStr<<"\n";
- else{
- myStr[index] = ch1;
- countA++;
- if(countA <= digit) think(index+1);
- countA--;
- myStr[index] = ch2;
- countB++;
- if(countA >=countB) think(index+1);
- countB--;
- }
- }
- int main(){
- std::cin>>digit;
- std::cin>>ch1>>ch2;
- myStr[2*digit]=0;
- think(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement