1.左下角打印
public static void main(String[] args){
for(int i=1;i<=9;i++){
for (int j=1;j<=i;j++){
System.out.printf("%d*%d = %-4d",j,i,i*j);
}
System.out.println();
}
}
效果截图
2.右上角打印
public static void main(String[] args){
for (int i=1;i<=9;i++){
int k;
for (k=1;k<=i-1;k++)
System.out.print("\t\t");
for (int j=i;j<=9;j++)
System.out.printf("%d*%d=%-4d",j,i,j*i);
System.out.println();
}
}
效果截