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 printStarln(int pos){
  11. while (pos > 0){
  12. if ((pos & 1) == 1){
  13. System.out.print("*");
  14. }else{
  15. System.out.print(" ");
  16. }
  17. pos >>= 1;
  18. }
  19. System.out.println();
  20. }
  21.  
  22. public static void main (String[] args) throws java.lang.Exception
  23. {
  24. Scanner sc = new Scanner(System.in);
  25. int n = sc.nextInt();
  26. int l1 = 1 << n-1;
  27. int l2 = 1;
  28. for (int i = 0; i < n; i++) {
  29. printStarln(l1 | l2);
  30. l1 >>= 1;
  31. l2 <<= 1;
  32. }
  33. sc.close();
  34. }
  35. }
Success #stdin #stdout 0.14s 52648KB
stdin
11
stdout
*         *
 *       *
  *     *
   *   *
    * *
     *
    * *
   *   *
  *     *
 *       *
*         *