Advertisement
Guest User

Untitled

a guest
May 21st, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class FE2DARR {
  3. public static void main(String[] args) {
  4. Scanner read = new Scanner(System.in);
  5. int row, col;
  6. int sum = 0;
  7. int rowsum = 0;
  8. System.out.println("Enter number of rows and columns");
  9. row = read.nextInt();
  10. col = read.nextInt();
  11. int list[][] = new int[row][col];
  12. for (int i = 0; i < row; i++) {
  13. System.out.println("Enter elemnts for row " + i + ":");
  14. for (int j = 0; j < col; j++) {
  15. list[i][j] = read.nextInt();
  16.  
  17. }
  18. }
  19. for (int j = 0; j < col; j++) {
  20. sum += list[0][j];
  21. }
  22. for (int i = 1; i < row; i++) {
  23. for (int j = 0; j < col; j++) {
  24. rowsum += list[i][j];
  25. }
  26.  
  27. if (sum == rowsum)
  28. {
  29. System.out.println("The Array is Magic");
  30. } else
  31. System.out.println("The Array is not Magic");
  32. }
  33.  
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement