在数组中查找键盘输入的整数。如果找到则输出该整数在数组中的序号,否则输出 “not found” 。
例如:运行程序
输入 99, 程序输出 : 99 在数组中的序号是 5
输入 59, 程序输出 :not found
【程序】
class Exam23{
public static void main(String[]args) throws IOException{
int ( 6 ) ={83,75,92,67,55,99,78,61};
Scanner sc=new Scanner(System.in));
int x=sc.nextInt();
int index=-1;
for(int i=0; ( 7 ) ;i++)
if (a[i]==x){
index=i;
break;
}
if( ( 8 ) )
System.out.println("not found");
else
System.out.println(index);
}
}