Enter 1234567, for example, I hope to put this number 7 in the array respectively
CodePudding user response:
When the letter read, char ch=getchar (); Or cin & gt;> Ch;Int n=ch - '0'; Thus from character transformed into digital
To put it in the array can
A predefined array greatly, enough to accommodate enough
The key is you don't know how long the input problem, s much array right?
If you know how long is the longest, it directly define the maximum length of the array
If you don't know, is about to the vector
#include
Vector
After read the letter, into digital ary. Push_back (n); Added to the array go inside
CodePudding user response:
It is better if can use the stringDefines figures, otherwise it'll have to save again