class pyramid {
// pyramid star pattern
public static void main(String[] args) {
int size = 5;
for (int i = 0; i < size; i++) {
// print spaces
for (int j = 0; j < size - i - 1; j++) {
System.out.print(" ");
}
// print stars
for (int k = 0; k < 2 * i + 1; k++) {
System.out.print("*");
}
System.out.println();
}
}
}
public static void StarPyramid(int n)
{
for (int i = 0; i < n; i++)
{
var bol = true;
for (int j = 0; j < 2*n; j++)
{
if(j+i>=n && j<=n+i)
{
if(bol)System.out.print("*");
else System.out.print(" ");
bol=!bol;
}
else System.out.print(" ");
}
System.out.println();
}
}
//for n =7
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
class hollowPyramid {
public static void main(String[] args) {
// size of the pyramid
int size = 5;
for (int i = 0; i < size; i++) {
// print spaces
for (int j = 0; j < size - i - 1; j++) {
System.out.print(" ");
}
// print stars
for (int k = 0; k < 2 * i + 1; k++) {
if (i == 0 || i == size - 1) {
System.out.print("*");
}
else {
if (k == 0 || k == 2 * i) {
System.out.print("*");
}
else {
System.out.print(" ");
}
}
}
System.out.println();
}
}
}