Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. public class Zad2Tab2Zestaw {
  2.     public static void main(String[] args) {
  3.         Scanner sc = new Scanner(System.in);
  4.         Random rnd = new Random();
  5.         int row;
  6.         int column;
  7.         do {
  8.             System.out.println("Enter the number of row");
  9.             row = sc.nextInt();
  10.             System.out.println("Enter the number of column");
  11.             column = sc.nextInt();
  12.         } while (row % 2 != 0 && row < 2 && column < 4);
  13.         System.out.println(row + " " + column);
  14.         int[][] tab = new int[row][column];
  15.         for (int i = 0; i < row; i++) {
  16.             for (int j = 0; j < column; j++) {
  17.                 tab[i][j] = rnd.nextInt(21) + 5;
  18.             }
  19.         }
  20.         int[][] tab1 = new int[row][column];
  21.  
  22.         for (int i = 0; i < row; i++) {
  23.             for (int j = 0; j < column; j++) {
  24.                 tab1[i][j] += 2 * tab[i][j];
  25.             }
  26.         }
  27.         System.out.println("First array element: " + Arrays.deepToString(tab));
  28.         System.out.println("Secondarray element: " + Arrays.deepToString(tab1));
  29.  
  30.         for (int i = 0; i < row; i++) {
  31.             for (int j = 0; j < column; j++){
  32.                 tab[i][j]= tab[0][0] + tab1[tab.length -1 -i]
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement