第三题

import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner cin=new Scanner (System.in); while (cin.hasNext()){ int a=cin.nextInt(); int []b=new int [a]; for(int i=0;i<a;i++) { b[i]=cin.nextInt(); } int c=cin.nextInt(); int []d =new int[c]; for(int i=0;i<c;i++) { d[i]=cin.nextInt(); } for(int i=0;i<a;i++) { int j; for(j=0;j<c;j++) { if(d[j]==b[i]) { System.out.println(true); break; } if(j==c-1) { System.out.println(false); } } } } } }

1 Response

这道题的输出为什么只有true没有false?

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.