Varasku

Iloczyn dwóch tablic

Nov 8th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1.  
  2. package lul;
  3.  
  4. import java.util.Arrays;
  5. import java.util.Random;
  6.  
  7.  
  8. public class LUL {
  9.  
  10.  
  11. public static void main(String[] args) {
  12. int iloczyn=0;
  13. Random r = new Random();
  14. int[]tt1 = new int[5];
  15. int[]tt2 = new int[5];
  16. for (int i=0; i<tt1.length;i++){
  17. tt1[i]=r.nextInt(10);
  18. tt2[i]=r.nextInt(10);
  19. iloczyn += tt1[i]*tt2[i];
  20. }
  21. System.out.println("tablica 1= "+Arrays.toString(tt1));
  22. System.out.println("Tablica 2= "+Arrays.toString(tt2));
  23. System.out.println("Wynik= "+iloczyn);
  24. }
Add Comment
Please, Sign In to add comment