CodePudding user response:
Feel LZ poisoning, this kind of code to write no more meaning,Will write a, it is ok to know the train of thought to solve the problem,
Give you reference code,
public class Sample {
Public static void main (String [] args) {
//Q1
for(int i=1; i<10; The upper i++) {//
For (int j=1; J<10; J++) {//left side
If (jSystem. The out. Printf (" % d % d *=% 2 d ", I, j, I * j);
} else {
System. The out. Printf (" % 6 s ", "");
}
}
For (int j=9; J> 0; J -) {//right side
If (jSystem. The out. Printf (" % d % d *=% 2 d ", I, j, I * j);
} else {
System. The out. Printf (" % 6 s ", "");
}
}
System.out.println();
}
For (int I=9. I> 0; I -) {//lower
For (int j=1; J<10; J++) {
If (j<=I) {//left side
System. The out. Printf (" % d % d *=% 2 d ", I, j, I * j);
} else {
System. The out. Printf (" % 6 s ", "");
}
}
For (int j=9; J> 0; J -) {//right side
If (jSystem. The out. Printf (" % d % d *=% 2 d ", I, j, I * j);
} else {
System. The out. Printf (" % 6 s ", "");
}
}
System.out.println();
}
System.out.println();
//Q2: Q1 half reverse printing can up and down, the code is not wrote
//Q3: print Q1 upper left side and the lower part of the left side is ok, the code is not wrote
//Q4: upper can print Q1, the code also don't write the
//Q5: print Q1 top half of the left side and right side of the lower
for(int i=1; i<10; The upper i++) {//
For (int j=1; J<10; J++) {//left side
If (jSystem. The out. Printf (" % d % d *=% 2 d ", I, j, I * j);
} else {
System. The out. Printf (" % 6 s ", "");
}
}
System.out.println();
}
For (int I=9. I> 0; I -) {//lower
For (int j=1; J<10; J++) {//left side are blank
System. The out. Printf (" % 6 s ", "");
}
For (int j=9; J> 0; J -) {//right side
If (jSystem. The out. Printf (" % d % d *=% 2 d ", I, j, I * j);
} else {
System. The out. Printf (" % 6 s ", "");
}
}
System.out.println();
}
}
}