You are on page 1of 7

#PATTERN 9

public static void main(String[] args)


{
//System.out.println("Hello World");
int n=5;
int row=1; //odd inc.
int str=1;
int sp1=4; //4 3 2 1
while(row<=n)
{
//space.
int i=1;
while(i<=sp1)
{
System.out.print(" ");
i++;
}
//star.
int j=1;
while(j<=str)
{
System.out.print("*"+" ");
j++;
}
//space.
int k=1;
while(k<=sp1)
{
System.out.print(" ");
k++;
}
//next prep.
System.out.println();
row++;
str=str+2;
sp1--;

}
}
}
#PATTERN 10
public static void main(String[] args)
{
//System.out.println("Hello World");
int n=5;
int row=1; //odd inc.
int str=9;
int sp1=0; //4 3 2 1
while(row<=n)
{
//space.
int i=1;
while(i<=sp1)
{
System.out.print(" ");
i++;
}
//star.
int j=1;
while(j<=str)
{
System.out.print("*"+" ");
j++;
}
//space.
int k=1;
while(k<=sp1)
{
System.out.print(" ");
k++;
}
//next prep.
System.out.println();
row++;
str=str-2;
sp1++;

}
}
#PATTERN 11
//System.out.println("Hello World");
int n=5;
int row=1; //odd inc.
int str=1;
int sp1=4; //4 3 2 1
while(row<=n)
{
//space.
int i=1;
while(i<=sp1)
{
System.out.print(" ");
i++;
}
//star.
int j=1;
while(j<=str)
{
System.out.print("*" +" ");
j++;
}
//space.
int k=1;
while(k<=sp1)
{
System.out.print(" ");
k++;
}
//next prep.
System.out.println();
row++;
str++;
sp1--;

}
}
#PATTERN 12
//System.out.println("Hello World");
int n=5;
int row=1; //odd inc.
int str=1;
int sp1=4; //4 3 2 1
while(row<=n)
{
//space.
int i=1;
while(i<=sp1)
{
System.out.print(" ");
i++;
}
//star.
int j=1;
while(j<=str)
{
if(j%2==0)
{
System.out.print("!"+" ");
}
else
{
System.out.print(" "+"*" +" ");
}
j++;
}
//space.
int k=1;
while(k<=sp1)
{
System.out.print(" ");
k++;
}
//next prep.
System.out.println();
row++;
str=str+2;
sp1--;

}
}
#PATTERN 23
int n=5;
int row=1; //odd inc.
int str=1;
int sp1=4; //4 3 2 1
while(row<=n)
{
//space.
int i=1;
while(i<=sp1)
{
System.out.print(" ");
i++;
}
//star.
int j=1;
while(j<=str)
{
System.out.print("1"+" ");
j++;
}
//space.
int k=1;
while(k<=sp1)
{
System.out.print(" ");
k++;
}
//next prep.
System.out.println();
row++;
str=str+2;
sp1--;
}
#PATTERN 24
int n=5;
int num=1;
int row=1; //odd inc.
int str=1;
int sp1=4; //4 3 2 1
while(row<=n)
{
//space.
int i=1;
while(i<=sp1)
{
System.out.print(" ");
i++;
}
//star.
int j=1;
while(j<=str)
{
System.out.print(num+" ");
j++;
}
//space.
int k=1;
while(k<=sp1)
{
System.out.print(" ");
k++;
}
//next prep.
System.out.println();
row++;
num++;
str=str+2;
sp1--;
}
#PATTERN 25
int n=5;
int num=1;
int row=1; //odd inc.
int str=1;
int sp1=4; //4 3 2 1
while(row<=n)
{
//space.
int i=1;
while(i<=sp1)
{
System.out.print(" ");
i++;
}
//star.
int j=1;
while(j<=str)
{
System.out.print(num+" ");
num++;
j++;
}
//space.
int k=1;
while(k<=sp1)
{
System.out.print(" ");
k++;
}
//next prep.
System.out.println();
row++;
str=str+2;
sp1--;
}
#PATTERN 26
int n=5;
int num=1;
int row=1; //odd inc.
int str=1;
int sp1=4; //4 3 2 1
while(row<=n)
{
//space.
int i=1;
while(i<=sp1)
{
System.out.print(" ");
i++;
}
//star.
int j=1;
while(j<=str)
{
System.out.print(num+" ");
num++;
j++;
}
//space.
int k=1;
while(k<=sp1)
{
System.out.print(" ");
k++;
}
//next prep.
num=1;
System.out.println();
row++;
str=str+2;
sp1--;
}
#PATTERN 29
int n=5;
int row=1; //odd inc.
int str=1;
int sp1=4; //4 3 2 1
while(row<=n)
{
//space.
int i=1;
while(i<=sp1)
{
System.out.print(" ");
i++;
}
//star.
int j=1;
while(j<=str)
{
if(j==1 || j==str)
{
System.out.print(row+" ");
}
else
{
System.out.print("0"+" ");
}
j++;
}
//space.
int k=1;
while(k<=sp1)
{
System.out.print(" ");
k++;
}
//next prep.
System.out.println();
row++;
str=str+2;
sp1--;
}
#PATTERN 30
int n=5;
int row=1; //odd inc.
while(row<=n)
{
int c=5;
//print nums.
while(c>=1)
{
System.out.print(c+" ");
c--;
}
//next prep.
System.out.println();
row++;
}
#PATTERN 31

int n=5;
int str=1;
int row=1; //odd inc.
while(row<=n)
{
int c=5;
//print nums.
while(c>=1)
{
if(c==str)
{
System.out.print("*"+" ");
}
else
{
System.out.print(c+" ");
}
c--;
}
//next prep.
System.out.println();
row++;
str++;
}

You might also like