Advertisement
StoneHaos

13

Nov 28th, 2021
722
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. string tothird(int n) {
  7.     if (n < 3)
  8.         return to_string(n);
  9.     return tothird(n / 3) + to_string(n % 3);
  10. }
  11.  
  12. int main() {
  13.     int n;
  14.     cin >> n;
  15.     cout << n << "(10) = " << tothird(n) << "(3)\n";
  16.     return 0;
  17. }
Advertisement
RAW Paste Data Copied
Advertisement