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. int i,j,k;
  13. int l=1;
  14. int m=0;
  15. int a=5;
  16. int b=a-1;
  17. //System.out.print("Please enter number rows:");
  18. //System.in.
  19. for(i=a; i>0; i--)
  20. {
  21. for(j=i; j>0; j--)
  22. {
  23. System.out.print(" ");
  24. }
  25. for(k=1; k<=l+m; k++)
  26. {
  27. System.out.print("*");
  28. }
  29. System.out.println("");
  30. l++;
  31. m++;
  32. }
  33.  
  34. l=b; m=b-1;
  35. for(i=b; i>0; i--)
  36. {
  37. for(j=b+1; j>=i; j--)
  38. {
  39. System.out.print(" ");
  40. }
  41. for(k=1; k<=l+m; k++)
  42. {
  43. System.out.print("*");
  44. }
  45. System.out.println("");
  46. l--;
  47. m--;
  48. }
  49.  
  50. }
  51. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
     *
    ***
   *****
  *******
 *********
  *******
   *****
    ***
     *