BlueBook

p287ex4 - First Blank

Find the first occurrence of a space (ASCII value 32) in a string.

Input

The first line of input contains an integer T (1 ≤ T ≤ 100), indicating how many lines of input are to follow. Each of the following T lines contains one string S, whose length is at least one but less than 100. Note that the string consists of the entire line; trailing spaces are part of the string.

Output

For each string given in input, print the position at which the first blank was found in that string, on one line. The first character in a string has position 1, the second 2, and so on. If no blank was found in the string, print 0 instead.

Sample Input

2
 2
22

Sample Output

1
0

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 26, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

do we like print either 0,1,or 2 or we print where the final blank is found, like (" 2,") should be 2 since there was two spaces, or 1, since that 1 was the first blank. help please(jargon, help me plz)

I really think the question is clear enough. There's a clarification question in another comment below as well.

my code seems right, whats wrong?


wow, it worked, thanks jargon!

so if the input was " 25" then the output should be "2" or "1"?

1: The space is the first character.
If, however, it was "25", it would be 0 because there is no space.