import java.util.*; public class Main{ public static void main(String args[]) { Scanner scanner=new Scanner(System.in); int num=scanner.nextInt(); int [] arr=new int[num]; for (int i = 0; i <arr.length ; i++) { arr[i]=scanner.nextInt(); } int goal=scanner.nextInt(); for (int i = 0; i <arr.length ; i++) { if (goal==arr[i]){ System.out.println(i+1); break; } else if(i==arr.length-1){ System.out.println("-1"); } } } }
蓝桥杯 试题 基础练习 查找整数
最新推荐文章于 2024-11-12 17:21:19 发布