109.1.. Učitati dva dvodimenzionalna niza i drugi čiji je opšti član: yi,j = xi,j + 3 (dodaj 3). Ispisati oba niza.
Listing programa:
package zad1;
import java.util.Scanner;
public class P10912019 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("unesi broj redova i kolona");
int n = input.nextInt();
int m = input.nextInt();
int x[][] = new int[n][m];
System.out.print("unesi clanove niza x");
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
x[i][j] = input.nextInt();
}
}
int y[][] = new int[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
y[i][j] = x[i][j] + 3;
}
}
System.out.println();
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
System.out.print(x[i][j] + " ");
}
System.out.println();
}
System.out.println();
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
System.out.print(y[i][j] + " ");
}
System.out.println();
}
}
}
Ispis na ekranu:
Index
|