一、第一种

代码:

public class ChengFaBiao {  
    public static void main(String[] args) {
		
		for(int i=1;i<=9;i++){
			for(int j=9;j>=i;j--){
				System.out.print(j + "*" + i + "=" + (j * i) + "\t");
		
			}
		
        System.out.println();
		}
	   }
	}

运行结果: 

二、第二种

代码:

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

运行结果:

三、第三种:

代码:

public class ChengFaBiao {  
    public static void main(String[] args) {  
        int maxFactor = 9; // 最大的乘数  
  
        // 外层循环控制行数  
        for (int i = maxFactor; i >= 1; i--) {   
            for (int space = maxFactor - i; space > 0; space--) {  
                System.out.print("\t"); // 打印制表符作为空格  
            }    
            for (int j = 1; j <= i; j++) {   
                System.out.print(j + "*" + i + "=" + (j * i) + "\t");  
            }  
            // 每打印完一行后换行  
            System.out.println();  
        }  
    }  
}

运行结果:

四、第四种

代码:

public class ChengFaBiao {  
    public static void main(String[] args) {  
        int maxFactor = 9; // 最大的乘数  
  
        // 外层循环控制行数  
        for (int i = maxFactor; i >= 1; i--) {   
            for (int space = maxFactor - i; space > 0; space--) {  
                System.out.print("\t"); // 打印制表符作为空格  
            }    
            for (int j = 1; j <= i; j++) {   
                System.out.print(j + "*" + i + "=" + (j * i) + "\t");  
                if (j < i) {  
                   System.out.print("\t");
                }  
            }  
            // 每打印完一行后换行  
            System.out.println();  
        }  
    }  
}

运行结果:

喜欢自己,比喜欢这个世界重要~      喜欢我就关注我叭~ 

 

 

 

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐