Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Task10_6_3 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- int[] numArr1 = new int[n];
- for (int i = 0; i < n; i++) {
- numArr1[i] = sc.nextInt();
- }
- int m = sc.nextInt();
- int[] numArr2 = new int[m];
- for (int i = 0; i < m; i++) {
- numArr2[i] = sc.nextInt();
- }
- intersetcion(numArr1, numArr2, n, m);
- }
- public static void intersetcion(int[] a, int[] b, int n, int m) {
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- if (a[i] == b[j])
- System.out.print(a[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment