Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Zad2Tab2Zestaw {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- Random rnd = new Random();
- int row;
- int column;
- do {
- System.out.println("Enter the number of row");
- row = sc.nextInt();
- System.out.println("Enter the number of column");
- column = sc.nextInt();
- } while (row % 2 != 0 && row < 2 && column < 4);
- System.out.println(row + " " + column);
- int[][] tab = new int[row][column];
- for (int i = 0; i < row; i++) {
- for (int j = 0; j < column; j++) {
- tab[i][j] = rnd.nextInt(21) + 5;
- }
- }
- int[][] tab1 = new int[row][column];
- for (int i = 0; i < row; i++) {
- for (int j = 0; j < column; j++) {
- tab1[i][j] += 2 * tab[i][j];
- }
- }
- System.out.println("First array element: " + Arrays.deepToString(tab));
- System.out.println("Secondarray element: " + Arrays.deepToString(tab1));
- for (int i = 0; i < row; i++) {
- for (int j = 0; j < column; j++){
- tab[i][j]= tab[0][0] + tab1[tab.length -1 -i]
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement