Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /*
- =====================================================
- chapter 6: Functions
- Ex6:
- =====================================================
- */
- public class MyProgram {
- public static boolean isRowEqualCol(int matrix[][]){
- int sumRow=0;
- int sumCol=0;
- for(int i=0;i<matrix.length;i++){
- for(int j=0;j<matrix.length;j++){
- sumRow+=matrix[i][j];
- sumCol+=matrix[j][i];
- }
- if(sumRow!=sumCol)
- return false;
- }
- return true;
- }
- public static void main(String[] args) {
- Scanner s=new Scanner(System.in);
- int size;
- boolean res;
- int matrix[][]={{2,1,5},{6,7,3},{0,8,0}};
- res=isRowEqualCol(matrix);
- System.out.println(res);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement