注意:位置从 1 开始!!!
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] nums = new int[sc.nextInt()];
for(int i = 0;i < nums.length;i++) {
nums[i] = sc.nextInt();
}
boolean have = false;
int target = sc.nextInt();
for(int i = 0;i < nums.length;i++) {
if(nums[i] == target) {
have = true;
System.out.println(i + 1);
break;//后面还可能有重复的值,不break会打印多个值
}
}
if(!have) System.out.println(-1);
sc.close();
}
}