开发者

Values of integers and calculations

Say you have a variable n1 which will be the value of three digits entered.

How can I then split n1 into 3 seperate integers, without knowing what exactly will be inpu开发者_如何学运维t?


divide by 10 in a loop and take the modulo?


It turns out that you do actually want to use a string. What you want to do is read a string as input and then break it down into the various segments. You would find the first 3 digits and turn it into an integer in n1, then read the next 2 digits and turn them into n2, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜