Advertisement
Sammy24

Untitled

Mar 14th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int baza(int n, int b)
  6. {
  7. int x = 0, p = 1, r;
  8. while(n)
  9. {
  10. r=n%b;
  11. x= x + r*p;
  12. p*=10;
  13. n/=b;
  14. }
  15. return x;
  16. }
  17.  
  18. int cmax(int n)
  19. {
  20. int maxim = 0;
  21. while(n)
  22. {
  23. if(n%10>maxim)
  24. {
  25. maxim = n%10;
  26. }
  27. n/=10;
  28. }
  29. return maxim;
  30. }
  31.  
  32. int main()
  33. {
  34. int n, k;
  35.  
  36. cin >> n >> k;
  37.  
  38. cout << cmax(baza(n, k));
  39.  
  40. return 0;
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement