Home > Back-end >  Looking for 250
Looking for 250

Time:01-22

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 ~

CodePudding user response:

Why a [0] discrepancy

CodePudding user response:

Ha ha ha, you don't laugh me, ok?

CodePudding user response:

reference 2 building self-confidence boy reply:
 # 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 ~

I seriously doubt you are pack to force in front of me, I don't understand you write the code?

CodePudding user response:

reference DJMJXM reply: 3/f
why a [0] discrepancy?

444666250-590,
520 is the third number

CodePudding user response:

Subject, points out that the input don't know how many the absolute value of no more than 1000 integer, so the above code is not in conformity with the question, because once the 1024th to meet the requirements that are unable to complete the task,

CodePudding user response:

reference 5 floor maggielve reply:
Quote: refer to the second floor confident boy reply:
 # 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 ~

I seriously doubt you are pack to force in front of me, I don't understand you write the code? nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related