生成九九乘法表的java
时间: 2023-05-17 11:06:29 浏览: 86
代码如下:
public class MultiplicationTable {
public static void main(String[] args) {
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j + "*" + i + "=" + i * j + "\t");
}
System.out.println();
}
}
}
这是一个简单的嵌套循环,用来生成九九乘法表。
相关问题
java生成九九乘法表
好的,以下是 Java 代码示例:
```java
public class MultiplicationTable {
public static void main(String[] args) {
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j + " * " + i + " = " + i * j + "\t");
}
System.out.println();
}
}
}
```
运行以上代码,即可输出九九乘法表。
Java生成九九乘法表
Sure, here is the Java code to generate a multiplication table:
```
public class MultiplicationTable {
public static void main(String[] args) {
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j + " x " + i + " = " + (i*j) + "\t");
}
System.out.println();
}
}
}
```
This code will output the multiplication table from 1x1 to 9x9.
阅读全文