for循环输出九九乘法表

126 阅读1分钟

/* 使用for循环输出九九乘法表:

1*1=1
1*2=2 2*2=4
1*3=3 2*3=6 3*3=9
1*4=4 2*4=8 3*4=12 4*4=16
..............
...................
1*9=9....................9*9=81

*/

public class ForTest08 {

public static void main(String[] args){

	for(int i=1;i<10;i++){//外层循环九次

		//i是行号
		//System.out.println(i);

		//循环体中的程序主要任务是什么?
		//处理当前行,将当前行所有的项目全部输出
		for(int j=1;j<=i;j++){
			System.out.print(i + "*" + j + "=" + i * j +" ");
		}

		System.out.println();
	}
}

}