Lucian_Adrian

#1509 NrMaxim

Feb 12th, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. int nrmaxim(int n)
  2. {
  3.  
  4. int nrm = 0, p = 1 , m = n;
  5. do{
  6. nrm ++, p *= 10, m /= 10;
  7. }while(m != 0);
  8. int max = 0;
  9. p /= 10;
  10. while(nrm){
  11. if(n > max)
  12. max = n;
  13. n = n % p * 10 + n / p;
  14. nrm --;
  15. }
  16. return max;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment