Advertisement
Farjana_akter

Untitled

Jun 29th, 2019
80
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. if(pos>3)
  7. {
  8. for(int i=1;i<=3;i++)
  9. cout<<x[i]<<" ";
  10. cout<<endl;
  11. return;
  12. }
  13. x[pos]=letter;
  14. cout<<x[pos]<<endl;
  15. if(pos==1)
  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,'a');
  31. combination(pos+1,'c');
  32. }
  33. else
  34. {
  35. combination(pos+1,'a');
  36. combination(pos+1,'b');
  37. }
  38.  
  39. }
  40. }
  41. int main()
  42. {
  43. combination(1,'a');
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement