标准九九乘法表
直接上经典九九乘法表,总有一款适合你
1.按惯例贴代码
public class TestMultiplication {
public static void main(String[] args) {
for (int i = 1; i < 10; i++) {
int k = 1;
for (int j = i; j < 10; j++,k++) {
System.out.print(k + " * " + j + " = " + k*j + "\t");
}
System.out.println();
}
System.out.println("------------分割线1------------");
for (int i = 1; i < 10; i++) {
for (int j = i; j < 10; j++) {
System.out.print(i + " * " + j + " = " + i*j + "\t");
}
System.out.println();
}
System.out.println("------------分割线2------------");
int i = 1;
while(true) {
int k = 1;
int j = i;
while(true) {
System.out.print(k + " * " + j + " = " + k*j + "\t");
j++;
k++;
if(j==10)break;
}
System.out.println();
i++;
if(i==10)break;
}
System.out.println("------------分割线3------------");
i = 1;
while(i<10) {
int k = 1;
int j = i;
while(j<10) {
System.out.print(k + " * " + j + " = " + k*j + "\t");
j++;
k++;
}
System.out.println();
i++;
}
System.out.println("------------分割线4------------");
i = 1;
do {
int j = i;
int k = 1;
do {
System.out.print(k + " * " + j + " = " + k*j + "\t");
j++;
k++;
}while(j<10);
System.out.println();
i++;
}while(i<10);
}
}
2.输出结果