fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8.  
  9. public static void print(int n){
  10. if(n<3 || n%2==0){
  11. System.out.println("enter a valid value");
  12. return;
  13. }
  14.  
  15. for(int i=0;i<n;i++){
  16.  
  17. for(int j=0;j<n/2;j++){
  18. System.out.print(" ");
  19. }
  20. for(int k=0;k<2;k++){
  21. System.out.print("*");
  22. }
  23. System.out.println();
  24. }
  25.  
  26. for(int i=0;i<n+1;i++){
  27. System.out.print("*");
  28. }
  29. }
  30.  
  31. public static void main (String[] args) throws java.lang.Exception
  32. {
  33. Scanner sc=new Scanner (System.in);
  34. int n=sc.nextInt();
  35. print(n);
  36. }
  37. }
Success #stdin #stdout 0.13s 56600KB
stdin
5
stdout
  **
  **
  **
  **
  **
******