Thread: I'm loooost

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    26

    Unhappy I'm loooost

    Uhh yes I got no clue where to begin. The assignment is to ask for an input up to 32,767 (short int, I know how to do this), then take that number and display it like this, with three spaces between.

    Input: 1234

    Output:
    0 1 2 3 4
    1 2 3 4
    2 3 4
    3 4
    4

    I got no clue. I've asked questions in class on how to go about it, professor said divide by 10,000 and use a mod on what was leftover or something of the like, but I don't understand how to rip the number apart, assign zero's to places which don't have a number, and then space it out by three.

    *Edit*

    I have to do this without loops btw.

    *Editx2 LOL*

    I sort of figured out that I have to use % to get the numbers but I still don't get how to "rip" them up into the format she wants.
    Last edited by OttoDestruct; 09-24-2003 at 02:36 PM.

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    1234 / 1000 = 1
    1234 %= 1000

    number is now 234

    234 / 100 = 2
    234 %= 100

    number is now 34

    34 / 10 = 3
    34 %= 10

    number is now 4

    and youre done
    I came up with a cool phrase to put down here, but i forgot it...

Popular pages Recent additions subscribe to a feed