java控制台打印减法口诀
直接上代码:
public class SubtractionTable {
public static void main(String[] args) {
sub();
}
public static void sub(){
for(int i = 2;i <= 10;i++){
for(int j = 1;j<=i;j++){
String format = String.format("%-7s",i+"-"+j+"="+(i-j));
System.out.print(format);
}
System.out.println();
}
}
public static void sub2(){
for(int i = 10;i >= 2;i--){
for(int j = 1;j<=i;j++){
String format = String.format("%-7s",i+"-"+j+"="+(i-j));
System.out.print(format);
}
System.out.println();
}
}
}