zl程序教程

您现在的位置是:首页 >  前端

当前栏目

一个for循环写出9*9乘法表

循环 一个 for 写出
2023-09-11 14:14:33 时间
public class ClassTest03 {
    public static void main(String[] args) {

        for(int i=1,j=1;j<=9;j++){
            if(i<j){
                i++;
                j=1;
                System.out.println("");
            }
            else{
                System.out.print(j+"*"+i+"="+i*j+"  ");
                //排版   低于两位数时多占一个空格
                if(i*j<10)
                System.out.print(" ");
            }
        }
    }
}