fork(3) 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. try{
  13. int a[][] = new int [4][5];
  14. int i,j;
  15. int s = 0;
  16.  
  17. for(i= 0;i<a.length; i++)
  18. for(j = 0; j<a[i].length; j++){
  19. a[i][j] = (int)(Math.random()*10);
  20. }
  21. for(i=0;i<a.length;i++){
  22. for(j=0;j<a[i].length;j++)
  23.  
  24. System.out.print(a[i][j] + "\t");
  25. System.out.println();
  26. }
  27.  
  28. for(j=0;j<a[0].length;j++){
  29. for(i=0;i<a.length;i++)
  30. if(a[i][j] >-1 && a[i][j]<1){
  31. s++;
  32.  
  33. }
  34. System.out.println("Zero in column no. "+j+" is "+s +"\t");
  35. s=0;
  36. }
  37. }catch(Exception e){
  38. System.out.println(e);
  39. }
  40.  
  41. }
  42. }
Success #stdin #stdout 0.1s 320320KB
stdin
Standard input is empty
stdout
8	4	1	6	3	
1	5	6	3	5	
0	3	8	9	6	
1	3	7	6	8	
Zero in column no. 0 is 1	
Zero in column no. 1 is 0	
Zero in column no. 2 is 0	
Zero in column no. 3 is 0	
Zero in column no. 4 is 0