Values of integers and calculations
Say you have a variable n1
which will be the value of three digits entered.
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.
精彩评论