Jump to content

splitting

- - - - -

  • Please log in to reply
2 replies to this topic

#1
SpaceCowboy

SpaceCowboy

    Newbie

  • Members
  • Pip
  • 8 posts
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
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1
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
SpaceCowboy

SpaceCowboy

    Newbie

  • Members
  • Pip
  • 8 posts
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