I am trying to print a shape based on input; the shape is an "x". The inputs must be positive odd ints, and an arbitrary brush character. I have the code completed for the user input, but I need help with the code that actually prints the shape. Here is what I have so far:
Code starts here for (int row = 0; row < height/2; row++) { for (int i = row; i > 0; i--) { System.out.print(" "); }
System.out.print(brush);
for (int i = (height/2); i >= 2*row; i--) {
System.out.print(" ");
}
System.out.print(brush);
System.out.print("\n");
}
for (int row = 1; row < (height/2)+1; row++ ) {
System.out.print(" ");
}
System.out.print(brush);
System.out.print("\n");
for (int row = (height/2)-1; row >= 0; row--) {
for (int i = row; i > 0; i--) {
System.out.print(" ");
}
System.out.print(brush);
for (int i = (height/2); i >= 2*row; i--) {
System.out.print(" ");
}
System.out.print(brush);
System.out.print("\n");
}
for (int row = 1; row < (height/2)+1; row++ ) {
System.out.print(" ");
Aucun commentaire:
Enregistrer un commentaire