Advertisement
_takumi

numerical converter

Jan 9th, 2021
1,433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n, k;
  6.     string res;
  7.     cin >> n >> k;
  8.     while (n > 0) {
  9.         res = to_string(n % k) + res;
  10.         n /= k;
  11.     }
  12.     cout << res;
  13.     return 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement