实现代码
public class Main {
public static void main(String[] args) {
test(9);
System.out.println("---------------------------");
test2(9);
}
public static void test(int value) {
if(value < 0) {
return;
}
test(value-1);
for(int i = 1; i<=value;i++) {
System.out.print(i +"*"+ value+ "=" + i*value+ "\t");
}
System.out.println();
return;
}
public static void test2(int value) {
for(int i = 1; i <= 9; i++) {
for(int j = 1; j <= i; j++) {
System.out.print(j + "*" + i+ "=" + j*i + "\t");
}
System.out.println();
}
}
}
截图: