Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- char x[5];
- void combination(int pos,char letter)
- {
- if(pos>3)
- {
- for(int i=1;i<=3;i++)
- cout<<x[i]<<" ";
- cout<<endl;
- return;
- }
- x[pos]=letter;
- cout<<x[pos]<<endl;
- if(pos==1)
- {
- combination(pos+1,'a');
- combination(pos+1,'b');
- combination(pos+1,'c');
- }
- else
- {
- if(letter=='a')
- {
- combination(pos+1,'b');
- combination(pos+1,'c');
- }
- else if(letter=='b')
- {
- combination(pos+1,'a');
- combination(pos+1,'c');
- }
- else
- {
- combination(pos+1,'a');
- combination(pos+1,'b');
- }
- }
- }
- int main()
- {
- combination(1,'a');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement