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 Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. int n=4;
  14. for(int i=1;i<=n;i++)
  15. {
  16. for(int k=1;k<n-i;k++)
  17. System.out.print(" ");
  18. int val=i;
  19. for(int j=1;j<=i;j++)
  20. {
  21. System.out.print(val+" ");
  22. val++;
  23.  
  24. }
  25. val-=2;
  26. for(int j=1;j<=i-1;j++)
  27. {
  28. System.out.print(val+" ");
  29. val--;
  30. }
  31. System.out.println();
  32. }
  33. }
  34. }
Success #stdin #stdout 0.15s 55636KB
stdin
Standard input is empty
stdout
  1 
 2 3 2 
3 4 5 4 3 
4 5 6 7 6 5 4