Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Создать двумерный массив из 5 строк по 8 столбцов в каждой из случайных
- целых чисел из отрезка [-99;99]. Вывести массив на экран. После на отдельной
- строке вывести на экран значение максимального элемента этого массива
- (его индекс не имеет значения).
- */
- public class DvumernieMassivi {
- public static void main(String[] args) {
- int[][] m = new int[8][5];
- for (int i = 0; i < m.length; i++) {
- for (int j = 0; j <m[i].length ; j++) {
- m[i][j] = (int) ((Math.random() *200-100));
- }
- }
- for (int i = 0; i < m.length; i++) {
- System.out.println();
- for (int j = 0; j < m[i].length; j++) {
- System.out.print(m[i][j] + " ");
- }
- }
- System.out.println();
- int counter = 0;
- for (int i = 0; i < m.length; i++) {
- for (int j = 0; j < m[i].length; j++) {
- if(counter < m[i][j]) {
- counter = m[i][j];
- }
- }
- }
- System.out.println("Max value = " +counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment