look which is wrong??????? Three bosses, my code on a test point, the other two, a prompt error, a direct wrong Topics are as follows:
Looking for 250
The other party don't want to talk to you, and throw a string of number to you... And you must be found in the string of Numbers "250" touching on the tall figure,
Input format: Don't know how many given in the input in a row the absolute value of no more than 1000 integer, which ensure that there are at least a "250",
The output format: In one line of output for the first time in "250" what is the other threw a digital counting (starting at 1), subject to ensure the output Numbers in the range of the integer
Input the sample: 13, 250, 888, 666, 123-233, 250-222 The output sample: 5 #
the include "stdio.h" Int main () { Int a, [1000]. Int I=1; While (getchar ()! ) ='\ n'{ The scanf (" % d ", & amp; A [I]); i++; } For (int I=1; ; I++) If (a [I]==250) { Printf (" % d ", I); break; } return 0; }
CodePudding user response:
Reference:
# include "stdio.h" Int main () { Int a, [1000]. Int I=1, j; While (getchar ()! ) ='\ n'{ The scanf (" % d ", & amp; A [I]); i++; } For (j=1; jIf (a) [j]==250) { Printf (" % d ", j); break; }
return 0; }
CodePudding user response:
# include & lt; Stdio. H>
Int main () { Int a, [1000]. Char buf [1024]. //int I=1;
The fgets (buf, sizeof (buf), stdin);
Int I=0, pos=0, k=0; While (buf [I]) { If (buf [I]=='\ n' | | buf [I]==0 | | buf [I]==' ') { If (buf [I]=='\ n' | | buf [I]==0) break; Sscanf (buf + pos, "% d", & amp; A, [k]). Printf (" % d \ n ", a [k]); k++; Pos=I + 1; } i++; } Buf [I]=0; Sscanf (buf + pos, "% d", & amp; A, [k]). k++;
/* While (getchar ()! ) ='\ n'{ The scanf (" % d ", & amp; A [I]); i++; } */ For (int I=0; I & lt; k; I++) If (a [I]==250) { //printf (" % d ", I); Printf (" % d ", I + 1); break; } return 0; }
For your reference ~
This time, I should and complexity of the problem of simple words ~