package com.ian.Struct;
//输出九九乘法表
public class ForDemo04 {
public static void main(String[] args) {
for (int j = 1; j < 10; j++) {
for (int i =1; i < j; i++) {
System.out.print(i+"*"+j+"="+(j*i)+"\t");
}
System.out.println();
}
}
}
- 先输出第一列
public class ForDemo04 {
public static void main(String[] args) {
for (int i = 1; i <= 9; i++) {
System.out.println(1+"*"+i+"="+(i*1));
}
}
}
- 外面嵌套一个for,同时修改输出参数
public class ForDemo04 {
public static void main(String[] args) {
for (int j = 1; j <= 9; j++) {
for (int i = 1; i <= 9; i++) {
System.out.println(j+"*"+i+"="+(i*j));
}
}
}
}
-
随着j增大,第一行一个,第二行两个,因此每一行i<=j
-
最后调整格式