線性搜索
Description
請撰寫一個程式,讓使用者輸入一個數列以及一個目標值,並且查找該目標值是否出現在數列中,若有則輸出索引值,反之則輸出-1。
Please write a program that allows the user to input a sequence and a target value, and find whether the target value appears in the sequence. If so, it will output the index value, otherwise it will output -1.
Input
輸入包含以下資訊:
第一行包含兩個正整數n(10≤n≤20),m,n代表數列的長度,m代表目標值。
�(10≤�≤20),�
�
�
第二行為使用者輸入的數列。
The input contains the following information:
The first line contains two positive integers n(10≤n≤20),m, n represents the length of the sequence, and m represents the target value.
�(10≤�≤20),�
�
�
The second line is a sequence of numbers entered by the user.
Output
請依照題目敘述進行輸出。
Please output according to the title description.
Sample Input 1
3 4
1 2 3
Sample Output 1
-1
Sample Input 2
5 10
77 50 10 364 123