Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Scanner;
- public class Test
- {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int[] arr = new int[5];
- int[] buff = new int[5];
- int i = 0;
- int c = 0;
- System.out.println("enter nums first aarray: ");
- while (i<5) {
- arr[i] = sc.nextInt();
- i++;
- }
- i = 0;
- System.out.println("enter nums second array: ");
- while (i<5) {
- buff[i] = sc.nextInt();
- i++;
- }
- i = 0;
- while (i<5) {
- while (c<5) {
- if (arr[c] == buff[i]) {
- System.out.println(arr[c]);
- break;
- }
- c++;
- }
- c = 0;
- i++;
- }
- System.out.println("first array: " + Arrays.toString(arr));
- System.out.println("second array: " + Arrays.toString(buff));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement