Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Targil35
- {
- static Scanner in = new Scanner (System.in);
- public static void main(String[] args)
- {
- int A;
- int B;
- int Z = 100;
- int c = 0;
- int count = 0;
- A = (int)(Math.random() * Z );
- B = (int)(Math.random() * Z );
- int[] a = new int[A];
- int[] b = new int[B];
- int[] z = new int[Z];
- for(int i = 0 ; i < Z ; i ++)
- z[i] = 0 ;
- System.out.println("Length of Array a: " + A);
- System.out.println("Length of Array b: " + B);
- for(int i = 0 ; i < A ; i ++)
- {
- a[i] = (int) (Math.random() * Z);
- System.out.println("Output: " + a[i]);
- System.out.println();
- }
- System.out.println();
- System.out.println();
- for(int i = 0 ; i < B ; i ++)
- {
- b[i] = (int) (Math.random() * Z);
- System.out.println("Output: " + b[i]);
- System.out.println();
- }
- for(int i = 0 ; i < A ; i ++)
- {
- for(int j = 0 ; j < B ; j ++)
- {
- if(a[i] == b[j])
- {
- z[a[i]] ++ ;
- }
- }
- }
- for(int i = 0 ; i < Z ; i ++)
- {
- if(b[i] != 0)
- {
- c ++;
- }
- }
- System.out.println();
- for(int i = 0 ; i < Z ; i++)
- {
- System.out.println(b[i] + " ");
- }
- System.out.println();
- System.out.println();
- System.out.println("c = " + c);
- int[] f = new int[c];
- for(int i = 0 ; i < Z ; i ++)
- {
- if(b[i] != 0)
- {
- f[count] = i;
- count ++;
- }
- }
- System.out.println();
- for (int i = 0 ; i < c ; i ++)
- System.out.println(f[i] + " ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement