Printing Pattern With Java
public static final String color_black="\u001B[30m";
public static final String reset="\u001B[0m";
int row = 11;
int col = 15;
int row_mid=row/2;
String[][]arr=new String[row][col];
for (int i=0; i<row; i++){
arr[i][0]="****";
}
int j=2;
for (int i=row_mid-1; i>=0; i--){
if(j<col){
arr[i][j]="****";
j=j+3;
}
}
int k=2;
for (int i=row_mid+1; i<row; i++){
if(k<col){
arr[i][k]="****";
k=k+3;
}
}
arr[5][3]="*";
int count=6;
while (count<=7){
for (int i=0; i<row; i++){
for (int l=0; l<col; l++){
if(arr[i][l]==null){
System.out.print(color_black+"*"+reset);
}
else{
String str="\u001B[9"+count+"m";
System.out.print(str+arr[i][l]+reset);
}
}
System.out.println();
}
count++;
System.out.println();
System.out.println();
}
Comments
Post a Comment