package chap2_流程控制.struct;
/**
* 九九乘法表(对齐方式 1.制表符 2.条件运算符)
* C语言 输出语句前加Tab也可对齐
*/
public class Test05 {
public static void main(String[] args) {
for (int i1 = 1; i1 <= 9; i1++) {
for (int j1 = 1; j1 <= i1; j1++) {
System.out.print(j1+"*"+i1+"="+i1*j1+"\t");//制表符\t
}
System.out.println();
}
System.out.println("======================================================================");
for (int i2 = 1; i2 <= 9; i2++) {
for (int j2 = 1; j2 <= i2; j2++) {
System.out.print(j2+"*"+i2+"="+(i2*j2<10 ? (" "+i2*j2) : i2*j2) +" ");//条件运算符(个位数对齐)
}
System.out.println();
}
}
}
10-16
1151