how do you split any number into digits i've done this formula Sum=1+n+n^ lets say i i write 9, the answer is 101 and now i need to separate those digits 1 0 1 and work with them... >< so how should i split those? :/
2 replies to this topic
#1
Posted 01 December 2010 - 04:08 PM
|
|
|
#2
Posted 01 December 2010 - 04:53 PM
I assume you mean binary representation. Here's recursive function
void toBinary(int number) {
if (number > 0) {
toBinary(number / 2)
cout << number % 2;
}
}
A conclusion is where you got tired of thinking.
#define class struct // All is public.
#3
Posted 01 December 2010 - 04:58 PM
ah i solved it my self but thenks anyway, even when i did i didnt solves my problem, i think splitting numbers is not an option for me ;D the thing is i need to find a max digit of a lets say 5 digit number 15947, the answer should be 9 and i cant get it, i thought i would split them and make my work easyer but even when i did that, it didnt helped
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









