Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package oppgaven;
- public class Eforsok {
- public static void main(String[] args) {
- int[] a = new int [5];
- for (int i=0; i < a.length;i++){
- a[i] = (int)(Math.random()*10);
- System.out.print(a[i]+" ");
- }
- System.out.println();
- int[] b = new int [5];
- for (int i=0; i < b.length;i++){
- b[i] = (int)(Math.random()*10);
- System.out.print(b[i]+" ");
- }
- System.out.println(felles(count));
- }
- public static int felles(int[] a, int[] b) {
- int count = 0;
- for (int i = 0; i <= a.length; i++) {
- for (int j = 0; j <= b.length; j++) {
- if ( a[i] == b[j]) {
- count++;
- }
- }
- }
- return count;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement