Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int nrmaxim(int n)
- {
- int aux=n;
- int nrcif=0;
- while(aux!=0)
- {
- nrcif++;
- aux=aux/10;
- }
- int p=1;
- for(int i=1;i<=nrcif;i++)
- p=p*10;
- long long numarnou=n*p+n;
- int max=n;
- int numar=0;
- for(int i=1; i<=nrcif;i++)
- {
- numar=numarnou%p;
- if(numar>max)
- max=numar;
- numarnou=numarnou/10;
- }
- return max;
- }
- int main()
- {
- cout<<nrmaxim(123456789);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement