package ifelse;
public class Patter_n {
public static void main(String[] args) {
pattern_x();
}
public static void pattern_x()
{
for(int row=1;row<=9;row++)
{
for(int col=1;col<=9;col++)
{
if(row==col || row+col==10) {
System.out.print("* ");
}
else {
System.out.print(" ");
}
}
System.out.println();
}
}
.........................................................................
OUTPUT:
* *
* *
* *
* *
*
* *
* *
* *
* *
package ifelse;
public class Patter_n {
public static void main(String[] args) {
// pattern_x();
pattern();
}
private static void pattern() {
// TODO Auto-generated method stub
for(int row=1;row<=9;row++)
{
for(int col=1;col<=9;col++) {
if(col==1 ||col==9 ||row==col || row+col==10) {
System.out.print("* ");
}
else {
System.out.print(" ");
}
}
System.out.println();
}
}
.........................................................................
OUTPUT:
* *
* * * *
* * * *
* * * *
* * *
* * * *
* * * *
* * * *
* *
package ifelse;
public class Patter_n {
public static void main(String[] args) {
// pattern_x();
pattern();
}
private static void pattern() {
// TODO Auto-generated method stub
for(int row=1;row<=9;row++)
{
for(int col=1;col<=9;col++) {
if( col==5 ||row==5 ||row==col || row+col==10) {
System.out.print("* ");
}
else {
System.out.print(" ");
}
}
System.out.println();
}
}
.........................................................................
OUTPUT:
* * *
* * *
* * *
* * *
* * * * * * * * *
* * *
* * *
* * *
* * *
package ifelse;
public class Patter_n {
public static void main(String[] args) {
// pattern_x();
// pattern();
pattern_c();
}
private static void pattern_c() {
// TODO Auto-generated method stub
for(int row=1;row<=9;row++)
{
for(int col=1;col<=9;col++) {
if(col==1 ||row==1 ||row==9 ) {
System.out.print("* ");
}
else {
System.out.print(" ");
}
}
System.out.println();
}
}
.........................................................................
OUTPUT:
* * * * * * * * *
*
*
*
*
*
*
*
* * * * * * * * *
package ifelse;
public class Patter_n {
public static void main(String[] args) {
// pattern_x();
// pattern();
pattern_c();
}
private static void pattern_c() {
// TODO Auto-generated method stub
for(int row=1;row<=9;row++)
{
for(int col=1;col<=9;col++) {
if(col==5||row==1 ||row==9 ) {
System.out.print("* ");
}
else {
System.out.print(" ");
}
}
System.out.println();
}
}
.........................................................................
OUTPUT:
* * * * * * * * *
*
*
*
*
*
*
*
* * * * * * * * *
public class Patter_n {
public static void main(String[] args) {
// pattern_x();
// pattern();
pattern_c();
}
private static void pattern_c() {
// TODO Auto-generated method stub
for(int row=1;row<=9;row++)
{
for(int col=1;col<=9;col++) {
if(col==1 ||col==9 ||row==col ) {
System.out.print("* ");
}
else {
System.out.print(" ");
}
}
System.out.println();
}
}
.........................................................................
OUTPUT:
* *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* *
Top comments (0)