程序效果:
程序截图:
程序源码:
// for九九乘法
System.out.println("for九九乘法**********************");
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();
}
System.out.println("while九九乘法**********************");
// while九九乘法
int a = 1;
while (a <= 9) {
int b = 1;
while (b <= a) {
System.out.print(b + "*" + a+ "=" + a * b + " ");
b++;
}
a++;
System.out.println();
}
System.out.println("dowhile九九乘法**********************");
// dowhile九九乘法
int c = 1;
do {
int v = 1;
do {
System.out.print( v+ "*" +c + "=" + (c * v) + "\t");
v++;
} while (v <= c);
c++;
System.out.println();
} while (c <= 9);