The user input four integer numbers in same line,for example,4857
After the input, I would like to place the four numbers into array
The result ,array = j
i is the position , j is number of input.

how to do it? must require to use substring? any other solutions?

Recommended Answers

All 3 Replies

You can do two things:
- Get the user input as a string (probably the easiest).
- Get the user input as an integer.

When you take the string:
- make substrungs
- parse the integer
- put the four integers in the array.

When you use the integer
- Take the remainder of dividing by 10, this is your last digit.
- add the number to the array
- divide the integer by 10
- repeat this four times.

Good luck!

thanks hiddepolen answering.
i think i can solve the application
thanks for your help!

Super! Please mark the thread as solved if it is solved!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.