Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5. string change124(int no)
  6. {
  7. string answer = "";
  8. int a;
  9. while(no > 0){
  10. a = no % 3;
  11. no = no / 3;
  12. if (a == 0){
  13. no -= 1;
  14. }
  15. answer = "412"[a] + answer;
  16. }
  17.  
  18. return answer;
  19. }
  20. int main()
  21. {
  22. int testNo = 6;
  23. string testAnswer = change124(testNo);
  24.  
  25. cout<<testAnswer;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement