Java实现九九乘法表口诀代码实现

九九乘法表正常输出,旋转180度输出
class JiuJiu{
    // 正常输出
	public void jiujiu1(){
		for(int i = 1; i <= 9; i++){
			for(int j = 1; j <= i; j++){
				if(i * j >= 10){
					System.out.print(i + "*" + j + "=" + i * j + " ");
				}else{
					System.out.print(i + "*" + j + "=" + i * j + "  ");
				}
			}
			System.out.println();
		}
	}
	// 旋转180度输出
	public void jiujiu2(){
		for(int i = 9; i > 0; i--){
			for(int k = 0; k < 9 - i; k++){
				System.out.print("       ");
			}
			for(int j = i; j > 0; j--){
				if(i * j >= 10){
					System.out.print(i + "*" + j + "=" + i * j + " ");
				}else{
					System.out.print(i + "*" + j + "=" + i * j + "  ");
				}
			}
			System.out.println();
		}
	}
	
	public static void main(String[] args){
		JiuJiu j = new JiuJiu ();
		j.jiujiu1();
		System.out.println();
		j.jiujiu2();
	}
}

你可能感兴趣的:(Java)