Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FE2DARR {
- public static void main(String[] args) {
- Scanner read = new Scanner(System.in);
- int row, col;
- int sum = 0;
- int rowsum = 0;
- System.out.println("Enter number of rows and columns");
- row = read.nextInt();
- col = read.nextInt();
- int list[][] = new int[row][col];
- for (int i = 0; i < row; i++) {
- System.out.println("Enter elemnts for row " + i + ":");
- for (int j = 0; j < col; j++) {
- list[i][j] = read.nextInt();
- }
- }
- for (int j = 0; j < col; j++) {
- sum += list[0][j];
- }
- for (int i = 1; i < row; i++) {
- for (int j = 0; j < col; j++) {
- rowsum += list[i][j];
- }
- if (sum == rowsum)
- {
- System.out.println("The Array is Magic");
- } else
- System.out.println("The Array is not Magic");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement