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. int cnt = 1;
  15. for (int i = 1; i <= n; i++)
  16. {
  17. for (int j = 1; j <= i; j++)
  18. {
  19. if (j == 1) System.out.print(cnt++); else System.out.print("*" + cnt++);
  20. }
  21. System.out.println();
  22. }
  23. for (int i = n; i >= 1; i--)
  24. {
  25. cnt -= i;
  26. for (int j = 1; j <= i; j++)
  27. {
  28. if (j == 1) System.out.print(cnt++); else System.out.print("*" + cnt++);
  29. }
  30. System.out.println();
  31. }
  32. }
  33. }
Success #stdin #stdout 0.13s 320576KB
stdin
Standard input is empty
stdout
1
2*3
4*5*6
7*8*9*10
7*8*9*10
8*9*10
9*10
10