chillurbrain

Task10_6_3

Dec 18th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Task10_6_3 {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6. int n = sc.nextInt();
  7. int[] numArr1 = new int[n];
  8. for (int i = 0; i < n; i++) {
  9. numArr1[i] = sc.nextInt();
  10. }
  11. int m = sc.nextInt();
  12. int[] numArr2 = new int[m];
  13. for (int i = 0; i < m; i++) {
  14. numArr2[i] = sc.nextInt();
  15. }
  16. intersetcion(numArr1, numArr2, n, m);
  17. }
  18. public static void intersetcion(int[] a, int[] b, int n, int m) {
  19. for (int i = 0; i < n; i++) {
  20. for (int j = 0; j < m; j++) {
  21. if (a[i] == b[j])
  22. System.out.print(a[i] + " ");
  23. }
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment