import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t=0;//次数 while(true) { int n=sc.nextInt(); int m=sc.nextInt(); if(n*n+m*m==0)break; System.out.println("CASE# "+(++t)+":"); int[] a=new int[n]; for (int i = 0; i < a.length; i++) { a[i]=sc.nextInt(); } Arrays.sort(a);//排序 int flag=0;//flag==0没找到 for (int i = 0; i < m; i++) { flag=0; int cur=sc.nextInt(); for (int j = 0; j < a.length; j++) { if(cur==a[j]) { flag=1; System.out.println(cur+" found at "+(j+1));//找到立马退出 break; } } if(flag==0) { System.out.println(cur+" not found"); } } } } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)