8

Run Settings
LanguageJava
Language Version
Run Command
class Main { public static void main(String[] args) { int[][] data = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; boolean[][] flag = new boolean[3][4]; // for (int i = 0; i < flag.length ; i++) { // for (int j = 0; j < flag[0].length ; j++) { // System.out.println(flag[i][j]); // } // } int N = 5; int [] points = new int [N]; int i = 0; while (i < N) { int rowIndex = (int) (Math.random() * data.length); int colIndex = (int) (Math.random() * data[0].length); if (flag[rowIndex][colIndex] == false) { points[i] = data[rowIndex][colIndex]; System.out.println(points[i]); flag[rowIndex][colIndex] = true; i = i + 1; } } } }
Editor Settings
Theme
Key bindings
Full width
Lines