9*9乘法表(5种输出格式)

时间:2023-01-08 22:35:55

 

格式1:

package chengfa;

public class Chengfabiao {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        for(int i=1;i<=9;i++){
            for(int j=1;j<=i;j++){
                //System.out.printf("%d%c%d%c%2d\t",i,'*',j,'=',i*j);
                System.out.print(i+"*"+j+"="+i*j+(j==i? "":"\t"));//*和=必须用双引号
                
            }System.out.println();
        }
        
        
    }

}

9*9乘法表(5种输出格式)

格式2:

package chengfa;

public class Chengfabiao {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        for(int i=1;i<=9;i++){
            for(int j=1;j<10;j++){
                //System.out.printf("%d%c%d%c%2d\t",i,'*',j,'=',i*j);
                System.out.print(i+"*"+j+"="+i*j+(j==i? "\t":"\t"));//*和=必须用双引号
                
            }System.out.println();
        }
        
        
    }

}

9*9乘法表(5种输出格式)

格式3:

package chengfa;

public class Chengfabiao {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        for(int i=9;i>=1;i--){
            for(int j=1;j<=i;j++){
                //System.out.printf("%d%c%d%c%2d\t",i,'*',j,'=',i*j);
                System.out.print(i+"*"+j+"="+i*j+(j==i? "\t":"\t"));//*和=必须用双引号
                
            }System.out.println();
        }
        
        
    }

}

9*9乘法表(5种输出格式)

格式4:

package chengfa;

public class Chengfabiao {

public static void main(String[] args) {
// TODO Auto-generated method stub
for(int i=1;i<10;i++){
for(int k=0;k<=(9-i)*7;k++){
System.out.print(" ");
}
for(int j=1;j<=i;j++){
System.out.printf("%d*%d=%2d ",i,j,j*i);
// System.out.print(i+"*"+j+"="+i*j+"\t");//*和=必须用双引号

}System.out.println();
}


}

}

9*9乘法表(5种输出格式)

 

格式5:

package chengfa;

public class Chengfabiao {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        for(int i=9;i>0;i--){
            for(int k=0;k<=(9-i)*7;k++){
                System.out.print(" ");    
            }
            for(int j=1;j<=i;j++){
                System.out.printf("%d*%d=%2d ",i,j,j*i);
                //System.out.print(i+"*"+j+"="+i*j+"\t");//*和=必须用双引号
                
            }System.out.println();
        }
        
        
    }

}

9*9乘法表(5种输出格式)