java递归99乘法表练习题
时间: 2023-11-04 16:55:26 浏览: 194
下面是一个使用递归方法打印九九乘法表的Java代码:
```java
public class JavaBasic07 {
public static void printMultiplicationTable(int num) {
if(num == 1) {
System.out.println("1 * 1 = 1");
return;
}
printMultiplicationTable(num - 1);
for(int i = 1; i <= num; i++) {
System.out.println(num + " * " + i + " = " + (num * i));
}
System.out.println();
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("请输入一个整数:");
int num = input.nextInt();
printMultiplicationTable(num);
input.close();
}
}
```
阅读全文