fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5.  
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. int N= scanner.nextInt();
  9. long []arr= new long[N];
  10.  
  11. for (int i = 0; i < N; i++) {
  12. arr[i]= scanner.nextLong();
  13. }
  14. long X= scanner.nextLong();
  15. boolean found= false;
  16.  
  17. for(int i=0;i<N;i++){
  18. if(X==arr[i]){
  19. System.out.println(i);
  20. found=true;
  21. break;
  22. }
  23. }
  24. if(!found){
  25. System.out.println(-1);
  26.  
  27. }
  28.  
  29. scanner.close();
  30. }
  31. }
  32.  
Success #stdin #stdout 0.11s 54636KB
stdin
5
1 3 0 4 5
10
stdout
-1