Advertisement
Farjana_akter

Untitled

Jun 29th, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. char x[5];
  4. void combination(int pos,char letter)
  5. {
  6. x[pos]=letter;
  7. // cout<<x[pos]<<endl;
  8. if(pos==3)
  9. {
  10. for(int i=1;i<=3;i++)
  11. cout<<x[i]<<" ";
  12. cout<<endl;
  13. return;
  14. }
  15. if(pos==0)
  16. {
  17. combination(pos+1,'a');
  18. combination(pos+1,'b');
  19. combination(pos+1,'c');
  20. }
  21. else
  22. {
  23. if(letter=='a')
  24. {
  25. combination(pos+1,'b');
  26. combination(pos+1,'c');
  27. }
  28. else if(letter=='b')
  29. {
  30. combination(pos+1,'c');
  31. combination(pos+1,'a');
  32. }
  33. else
  34. {
  35. combination(pos+1,'a');
  36. combination(pos+1,'b');
  37. }
  38.  
  39. }
  40. }
  41. int main()
  42. {
  43. combination(0,'a');
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement