Search for Integers
Import java. io. *; public class Main {public static void main (String [] args) throws Exception {BufferedReader bf = new BufferedReader (new InputStreamReader (System. in); int a = Integer. parseInt (bf. readLine (); int B [] = new int [a]; String s [] = bf. readLine (). split (""); int c = Integer. parseInt (bf. readLine (); int number =-1; int j = 0, I = 0; for (I = 0; I <s. length; I ++) {B [I] = Integer. parseInt (s [I]) ;}for (I = 0; I <a; I ++) {if (B [I] = c) {number = I + 1; break;} System. out. println (number );}}
Problem description
Returns a series containing n integers. the first occurrence of integer a in the series is the nth.
Input Format
The first line contains an integer n.
The second row contains n non-negative integers, which are the given series. Each number in the series is not greater than 10000.
The third row contains an integer a, which is the number to be searched.
Output Format if a appears in the series, output the position where it appears for the first time (the position starts from 1); otherwise, output-1. Sample Input 6
1 9 4 8 3 9
Sample 9 output 2 data scale and Convention 1 <= n <= 1000.