Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n,p,nr,M;
  8. cin>>n;
  9. M=0;
  10. p=1000000000;
  11. while(p>n)
  12. p=p/10;
  13. while(p>0){
  14. nr=(n/p/10)*p+n%p;
  15. if(nr>M)
  16. M=nr;
  17. p=p/10;
  18. }
  19. cout<<M;
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement