Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class array2 {
- public static void main(String[] args) {
- int[][] a = new int[5][2];
- fil(a);
- System.out.print("befoe");
- print(a);
- int max = 0;
- max(a);
- System.out.print("the max is " + max);
- re(a);
- System.out.println("after");
- print(a);
- }
- public static void fil(int[][] a) {
- Scanner in = new Scanner(System.in);
- for (int r = 0; r < a.length; r++) {
- for (int c = 0; c < a[r].length; c++) {
- System.out.println("Enter data to row " + (r + 1) + " and clome " + (c + 1));
- a[r][c] = in.nextInt();
- }
- }
- }
- public static void max(int[][] m) {
- int max = 0;
- for (int r = 0; r < m.length; r++) {
- for (int c = 0; c < m[r].length; c++) {
- if (m[r][c] > max)
- max = m[r][c];
- }
- }
- }
- public static void print(int[][] a) {
- for (int r = 0; r < a.length; r++) {
- for (int c = 0; c < a[r].length; c++) {
- System.out.print(a[r][c] + " ");
- }
- System.out.println();
- }
- }
- public static void re(int[][] t) {
- int temp = 0;
- for (int r = 0; r < t.length-1; r++) {
- for (int c = 0; c < t[r].length-1; c++) {
- temp = t[0][0];
- t[r][c] = t[r + 1][c + 1];
- t[t.length - 1][t[r].length - 1] = temp;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement