| 66 | } |
| 67 | |
| 68 | public static void butterfly(int n) { |
| 69 | //1st half |
| 70 | for(int i=1; i<=n; i++) { |
| 71 | //stars |
| 72 | for(int j=1; j<=i; j++) { |
| 73 | System.out.print("*"); |
| 74 | } |
| 75 | |
| 76 | //spaces |
| 77 | for(int j=1; j<=2*(n-i); j++) { |
| 78 | System.out.print(" "); |
| 79 | } |
| 80 | |
| 81 | //stars |
| 82 | for(int j=1; j<=i; j++) { |
| 83 | System.out.print("*"); |
| 84 | } |
| 85 | |
| 86 | System.out.println(); |
| 87 | } |
| 88 | |
| 89 | //2nd half |
| 90 | for(int i=n; i>=1; i--) { |
| 91 | //stars |
| 92 | for(int j=1; j<=i; j++) { |
| 93 | System.out.print("*"); |
| 94 | } |
| 95 | |
| 96 | //spaces |
| 97 | for(int j=1; j<=2*(n-i); j++) { |
| 98 | System.out.print(" "); |
| 99 | } |
| 100 | |
| 101 | //stars |
| 102 | for(int j=1; j<=i; j++) { |
| 103 | System.out.print("*"); |
| 104 | } |
| 105 | |
| 106 | System.out.println(); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | public static void solid_rhombus(int n) { |
| 111 | for(int i=1; i<=n; i++) { |