Advertisement
hpilo

Chapter6_Func_Ex6

Dec 15th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import java.util.Scanner;
  2. /*
  3. =====================================================
  4. chapter 6: Functions
  5.  
  6. Ex6:
  7. =====================================================
  8. */
  9.  
  10. public class MyProgram {
  11. public static boolean isRowEqualCol(int matrix[][]){
  12. int sumRow=0;
  13. int sumCol=0;
  14.  
  15. for(int i=0;i<matrix.length;i++){
  16. for(int j=0;j<matrix.length;j++){
  17. sumRow+=matrix[i][j];
  18. sumCol+=matrix[j][i];
  19. }
  20. if(sumRow!=sumCol)
  21. return false;
  22. }
  23.  
  24. return true;
  25. }
  26. public static void main(String[] args) {
  27. Scanner s=new Scanner(System.in);
  28. int size;
  29. boolean res;
  30.  
  31. int matrix[][]={{2,1,5},{6,7,3},{0,8,0}};
  32. res=isRowEqualCol(matrix);
  33. System.out.println(res);
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement