java乘法表

来源:百度知道 编辑:UC知道 时间:2024/06/23 02:32:14
1*1=1
2*1=2 2*2=4
3*1=3 3*2=6 3*3=9
4*1=4 4*2=8 4*3=12 4*4=16
5*1=5 5*2=10 5*3=15 5*4=20 5*5=25

怎么用while写?

int i = 1;
while (i <= 5)
{
int j = 1;
while (j <= i){
System.out.print(i + " * " + j + " = " + (i * j) + "\t" );
j++;
}
System.out.println();
i++;
}

一看就是学生为完成老师布置的作业来的,楼上的说的是正确的、、

public class io{
public static void main(String[] args){
int i=1;
while(i<=9){
for(int n=1;n<=i;n++){
System.out.print(n + "*" + i + "="+ n*i + " ");
}
System.out.println();
i++;
}
}
}

package bao;

public class Test2 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO 自动生成方法存根
for (int row = 1; row <= 9; row++) { // 循环行
for (int col = 1; col <= row; col++) { // 循环列
System.out.print(row + "*" + col + "=" + row * col)