fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int i;
  13. int j;
  14. int count = 0;
  15. int [][] arr = {{3, 0, 0, 6}, {4, 0, 1, 0}};
  16.  
  17. for (i = 0; i < arr.length; i++)
  18. {
  19. System.out.println();
  20. for (j = 0; j < arr[i].length; j++)
  21. {
  22. System.out.print(arr[i][j] + ", ");} }
  23. System.out.println();
  24. //--------------------------------------------------------------------
  25.  
  26. for (i = 0; i<arr.length; i++)
  27. for (j = 0; j<arr[i].length; j++)
  28. if (arr[i][j] == 0)
  29. {
  30. count++;
  31. break;
  32. }
  33. System.out.println("the amount of rows containing zeros = " + count);
  34.  
  35. //--------------------------------------------------------------------
  36. count=0;
  37.  
  38. for (i = 0; i<arr[0].length; i++)
  39. for (j = 0; j<arr.length; j++)
  40. if (arr[j][i] == 0)
  41. {
  42. count++;
  43. break;
  44. }
  45. System.out.println("the amount of cols containing zeros = " + count);
  46. }
  47. }
Success #stdin #stdout 0.09s 320576KB
stdin
Standard input is empty
stdout
3, 0, 0, 6, 
4, 0, 1, 0, 
the amount of rows containing zeros = 2
the amount of cols containing zeros = 3