Java Pattern Printing #13
Program:
public class PatternClass {
public static void main(String[] args)
{
System.out.println("The Pattern is");
int w11=8;
for(int i=1;i<=9;i++)
{
int p=i;
p=p+w11;
for(int j=1;j<=9;j++)
{
if((j==i)||(j==p))
{
System.out.print("x");
}
else
{
System.out.print(" ");
}
}
w11=w11-2;
System.out.println();
}
}
}
output:
* *
* *
* *
* *
*
* *
* *
* *
* *
Program:
public class PatternClass {
public static void main(String[] args)
{
System.out.println("The Pattern is");
int w11=8;
for(int i=1;i<=9;i++)
{
int p=i;
p=p+w11;
for(int j=1;j<=9;j++)
{
if((j==i)||(j==p))
{
System.out.print("x");
}
else
{
System.out.print(" ");
}
}
w11=w11-2;
System.out.println();
}
}
}
output:
* *
* *
* *
* *
*
* *
* *
* *
* *
No comments:
Post a Comment