public class testNineNine {
//左下角乘法表
public static void main(String[] args) {
System.out.println("打印九九乘法表");
//两层循环,外层控制行 内层控制列
//左下角乘法表
for( int i = 1 ; i <= 9 ; i++ ) {
for( int j = 1 ; j <= i ; j++ ) { // 当i = j时停止
System.out.print( j + " x " + i + " = " + i * j + "\t");
}
System.out.println();
}
}
}
//左上角乘法表
for( int i = 1 ; i <= 9 ; i++ ) {
for( int j = 9 ; j >= i ; j-- ) {
System.out.print( j + " x " + i + " = " + i * j + "\t");
}
System.out.println();
}
//右上角乘法表
for( int i = 9 ; i >= 1 ; i-- ) {
for( int j = 9 ; j >= 1 ; j-- ) {
if( j > i ) {
System.out.print("\t");
} else {
System.out.print( i + "x" + j + "=" + i * j + "\t");
}
}
System.out.println();
}
//右下角乘法表
for( int i = 1 ; i <= 9 ; i++ ) {
for(int t = 1;t<=9-i;t++) {
System.out.print("\t");
}
for( int j = 1 ; j <= i ; j++ ) {
System.out.print( i + "x" + j + "=" + i * j + "\t");
}
System.out.println();
}