Java实现九九乘法表的小例子_java

分享到:

 代码如下:


public class NMumDemo {
    public static void main(String args[]){
        int i,j,n=9;
        System.out.print(" * |");
        System.out.print(" 1");
        for(i=2;i<=n;i++)
            System.out.print("  "+i);
        System.out.print("\n---|");
        for(i=1;i<=n;i++)
            System.out.print("----");
        System.out.println();
        for(i=1;i<=n;i++){
            System.out.print(" "+i+" |");
            for(j=1;j<=i;j++)
            {
                int test=i*j/10;
                if(test<1) System.out.print(" "+i*j+" ");
                else if(test>=1) System.out.print(" "+i*j);
            }               
            System.out.println();
        }       
    }
}

效果如图:

昵    称:
验证码:

相关文档: