fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #define LOL "0123456789ABCDEF"
  5.  
  6. void gor2(int a, int p, char *c)
  7. {
  8. static int i = 0, n;
  9. if (a)
  10. {
  11. ++i;
  12. gor2(a / p, p, c);
  13. c[n - i--] = LOL[a % p];
  14. }
  15. else
  16. c[n = i] = '\0';
  17. }
  18.  
  19. int main()
  20. {
  21. char s[1024] = "2";
  22. gor2(3, 5, s);
  23. cout << s << endl;
  24. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
3