0

HELP! with a simple code

Hello everyone! I can't find the correct code for a simple thing: INVERT A NUMBER with RECURSION, using a function, on C++, if someone can help me, I will be so grateful. Pd: I want to get the value of the invert number, not just show it THANKS!

20th Jul 2018, 1:59 AM
Elías Mauricio Espínola
Elías Mauricio Espínola - avatar
4 ответов
+ 1
Where is your attempted code?
20th Jul 2018, 2:26 AM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
0
int invertir (int n){ if (n<10) return n; else { return invertir (n/10); } }
20th Jul 2018, 2:29 AM
Elías Mauricio Espínola
Elías Mauricio Espínola - avatar
0
If you pass any number to it, It'll return 0. Because the function throws first dight away at "n / 10".
20th Jul 2018, 4:59 AM
Disvolviĝo;
Disvolviĝo; - avatar
0
Thank you Robin! You'd been very helpful! Thanks! Your code works perfectly! 💪💪💪
20th Jul 2018, 12:01 PM
Elías Mauricio Espínola
Elías Mauricio Espínola - avatar