+ 1
Sololearn question: please any one explain me this
long n=7654321; long rev=0, rv=1; do{ long r=n % 10; if(r%2 > 0) rev = (rev * 10 ) + r; else System.out.println("r ="+r+(rv * r / 10)); n=n/10; }while(n>0); System.out.println("->"+rev);
5 Respuestas
+ 1
But the output was like
2:0
4:0
6:0
-->1003005007
0
Dear, was even hard to see it's really Java! Had to rewrite it for me to see what it's doing, and, this is the good news, it's really simple. The code loops over any given long / integer number to list all is uneven digits beginning with the last digit. Try it out in readable version...
0
Here it is:
https://code.sololearn.com/cLUkEtENffGI/?ref=app
0
It's almost the same with a few zeros 🙃 I just replaced them with some messages to see what the code is doing. My code was just to explain it.
0
I've enhanced the readability a little bit, maybe it's more clear now.