Home > Back-end > [C language help] part of the single digits calculator (individual)
[C language help] part of the single digits calculator (individual)
Time:03-23
#include #include #include #include //useless Void main () { { Printf (" hw additional \ n "); Int I, j=0, n [1000].
Char a, [1000]. Gets (a);//input string, such as: 1-2 For (int k=0;; K++) { If (a [k] <='9' & amp; & A [k] & gt;='0')//if the character for the digital {
A, sscanf (" % d ", & amp; N [j]);//character can be converted to an integer
Printf (" n [% d]=% d ", j, n [j]);
j++;
} Else if (a [k]=='\ n')//meet end enter { break; }
} }
The purpose of this code is the plus or minus, skip the input string will be digital Characters into integer and assign n [j]
Question: should always be done only for the first time, such as input 1 to 2, then the result is: n [0]=1, Don't know where is at the back of the 2