fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. string digits[36] = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R","S", "T", "U", "V", "W", "X", "Y", "Z"};
  5.  
  6. int rec(int n, int b)
  7. {
  8. if (n>b-1)
  9. rec(n/b, b);
  10. cout << digits[n%b];
  11. }
  12.  
  13. int main() {
  14. int n, b;
  15. cin >> n >> b;
  16. if (n<0)
  17. {
  18. cout<<"-";
  19. rec(-n, b);
  20. }
  21. else
  22. rec(n, b);
  23. return 0;
  24. }
Success #stdin #stdout 0s 4336KB
stdin
-34 18
stdout
-1G