-->
当前位置:首页 > 题库

PROGRAMMING:Find integer

Luz5年前 (2021-05-10)题库403
####Description
Find a given value key in an integer sequence with n elements, and output the position where the key first appears in the sequence.
For example: in the sequence [1,2,3,5,8,0,2,1,7,9,5,13], the result of finding 5 is 4, which means that it is found and first appears at position 4 (the fourth number)
####Input
The first line contains a positive integer k, indicating that there are k groups of test data. 1 <= k <= 100。 Then there are k sets of data.
For each group of data, it first contains a row of two integers, N and key, which represent the number of elements in the integer sequence of the group of data, N, and the value key to be searched( 1 <=n<=1000)
Then a row of contains n integers, each element of the sequence is given in turn, and the adjacent two integers are separated by a single space.
The absolute value of all elements and keys in the title should not exceed 10000.
####Output
For each group of data, if there is a key in the sequence, the position where the key first appears is output; Otherwise output - 1.
Each output occupies a separate line.
####Sample input
```in
three
5 3
2 3 3 6 7
4 5
1 2 3 4
1 1
one
```
###Sample output
```out
two
-1
one
```






answer:If there is no answer, please comment