Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. package oppgaven;
  2. public class Eforsok {
  3.  
  4.  
  5. public static void main(String[] args) {
  6. int[] a = new int [5];
  7. for (int i=0; i < a.length;i++){
  8. a[i] = (int)(Math.random()*10);
  9. System.out.print(a[i]+" ");
  10. }
  11. System.out.println();
  12.  
  13. int[] b = new int [5];
  14. for (int i=0; i < b.length;i++){
  15. b[i] = (int)(Math.random()*10);
  16. System.out.print(b[i]+" ");
  17. }
  18.  
  19. System.out.println(felles(count));
  20.  
  21. }
  22. public static int felles(int[] a, int[] b) {
  23. int count = 0;
  24.  
  25. for (int i = 0; i <= a.length; i++) {
  26. for (int j = 0; j <= b.length; j++) {
  27. if ( a[i] == b[j]) {
  28. count++;
  29. }
  30. }
  31. }
  32. return count;
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement