public class tabliczka2 { int j = 5; int i = 5; int tab[][]; public tabliczka2(int i, int j) { this.j = j; this.i = i; tab = new int[i][j]; } public void wypelnij(int a, int b, int wielX, int wielY) { for (int x = 0; x <= wielX; x++) { for (int y = 0; y <= wielY; y++) { tab[x][y] = (int) (Math.random() * (b - a) + a); } } } public void usunNaj() { int naj = 0, xNaj = -1, yNaj = -1; for (int x = 0; x < tab.length; x++) { for (int y = 0; y < tab[x].length; y++) { if (tab[x][y] >= naj) { naj = tab[x][y]; xNaj = x; yNaj = y; } } } for (int x2 = 0; x2 < tab.length; x2++) { tab[x2][yNaj] = 0; } for (int y2 = 0; y2 < tab[xNaj].length; y2++) { tab[xNaj][y2] = 0; } System.out.println("Najwiekszy element to: " + naj); } public void wyswietl() { for (int x = 0; x < tab.length; x++) { System.out.print(x + " | \t"); for (int y = 0; y < tab[x].length; y++) { System.out.print(tab[x][y] + "\t"); } System.out.println(); } } public static void main(String[] args) { tabliczka2 test = new tabliczka2(4, 4); test.wypelnij(10, 50, 2, 2); test.wyswietl(); test.usunNaj(); test.wyswietl(); } }