import java.io.*; import java.util.Scanner; public class sparseMatrix { static int MAX = 100; static boolean isSparse(int array[][], int m, int n) { int counter = 0; for (int i = 0; i < m; ++i) for (int j = 0; j < n; ++j) if (array[i][j] == 0) ++counter; return (counter > ((m * n) / 2)); } public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter the number of rows of the matrix:"); int m = sc.nextInt(); System.out.println("Enter the number of columns of the matrix:"); int n = sc.nextInt(); int array[][] = new int[m][n]; System.out.println("Enter the matrix elements:"); for (int i = 0; i < m; ++i) for (int j = 0; j < n; ++j) array[i][j] = sc.nextInt(); sc.close(); if (isSparse(array, m, n)) System.out.println("Yes"); else System.out.println("No"); } }