+ 1

Hi guys ,how it works ,how??? especially middle part(m*10+n%10)(n=n/10)

https://code.sololearn.com/cjZSnTjYDCS5/?ref=app

1st Dec 2020, 6:43 PM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar
6 ответов
+ 3
n%10 gets the remainder of a divide by ten so 123%10 is 3 as 120 is 12*10 leaving the 3. n=n/10 drops the ones column so 123/10 is 12. m=m*10+n%10 shifts m up a column and adds the new digit so 12*10+3 becomes 123.
1st Dec 2020, 7:19 PM
John Wells
John Wells - avatar
+ 1
too hard and confuse
1st Dec 2020, 7:55 PM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar
+ 1
output will be 321 after that?
1st Dec 2020, 7:55 PM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar
+ 1
If input is 123, Line 8 makes m=0 Line 9 is true Line 11 makes m=3 Line 12 makes n=12 Line 9 is true Line 11 makes m=32 Line 12 makes n=1 Line 9 is true Line 11 makes m=321 Line 12 makes n=0 Line 9 is false
1st Dec 2020, 8:22 PM
John Wells
John Wells - avatar
+ 1
thank u very much)
1st Dec 2020, 8:24 PM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar
+ 1
I get it
1st Dec 2020, 8:24 PM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar