fork 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 test
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11.  
  12. // your code goes here
  13. { int a[][] = new int[3][3];
  14. init (a);
  15. data (a);
  16. prnt (a);
  17. }
  18.  
  19. static void init(int a[][]){
  20. for (int i=0; i <3; i++)
  21. for(int j=0; j<3; j++)
  22. a[i][j] = 0;
  23. }
  24. static void data(int a[][]){
  25. int v = 1;
  26. for (int i=0; i <3; i++)
  27. for(int j=i; j<3; j++)
  28. a[i][j] = v++;
  29. }
  30. static void prnt(int a[][]){
  31. for (int i=0; i <3; i++){
  32. for(int j=0; j<3; j++){
  33. if (a[i][j] == 0)
  34. System.out.printf(" ");
  35. else
  36. System.out.printf("%d ", a[i][j]);
  37.  
  38. }
  39. System.out.println();
  40. }
  41. }
  42. }
Success #stdin #stdout 0.15s 55908KB
stdin
Standard input is empty
stdout
1 2 3 
  4 5 
    6