陈旺


私信TA

用户名:cw0824ly

访问量:9697

签 名:

等  级
排  名 121
经  验 7544
参赛次数 2
文章发表 61
年  龄 18
在职情况 学生
学  校 湖北生物科技职业学院
专  业

  自我简介:

TA的其他文章

解题思路:此题为输出题,需要注意输出数字前空格数分别是:1 3(十位数前空格为2)

注意事项:注意空格数

参考代码:

public class Main{

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
/*  Nine-by-nine Multiplication Table
--------------------------------------
     1   2   3   4   5   6   7   8   9
--------------------------------------
 1   1
 2   2   4
 3   3   6   9
 4   4   8  12  16
 5   5  10  15  20  25
 6   6  12  18  24  30  36
 7   7  14  21  28  35  42  49
 8   8  16  24  32  40  48  56  64
 9   9  18  27  36  45  54  63  72  81
--------------------------------------*/
		System.out.println("  Nine-by-nine Multiplication Table");
		System.out.println("--------------------------------------");
		System.out.println("     1   2   3   4   5   6   7   8   9");
		System.out.println("--------------------------------------");
		for (int i = 1; i <=9; i++) {
			System.out.print(" "+i+"   ");
			for (int j = 1; j <=i; j++) {
				if (i*j==6&&i!=6) {
					System.out.print(i*j+"   ");
				}
				else if (i*j>=5) {
					System.out.print(i*j+"  ");
				} 
				else {
					System.out.print(i*j+"   ");
				}
				
			}
			System.out.println();
			
			
		}
		System.out.println("--------------------------------------");
	}

}


 

0.0分

3 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区