JAVA输出九九乘法表,用for,dowhile,while循环语句输出

来源:互联网 发布:东莞网站建设优化技术 编辑:程序博客网 时间:2024/06/05 04:26

程序效果:


程序截图:



程序源码:

// 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);

1 0
原创粉丝点击