九九乘法表

public class Jjcfb{
    public static void main(String [] args){
        printb1();
        printb2();
    }    
    public static void printb1(){
        for(int i=1; i<=9;i++){
            for(int k =1;k<=9-i;k++){/*打印空格*/
                    System.out.print("     ");
            }        
            for(int j =1; j<=i; j++){
                int re = j*i;
                if (re<10){
                    System.out.print(j+"×"+i+"= "+re+"  ");
                }else{
                    System.out.print(j+"×"+i+"="+re+"  ");  
                 }
               
            }
        System.out.println();
        }
    }
    public static void printb2( ){
        for(int i=9; i>=1;i--){
            for(int k =1;k<=9-i;k++){/*打印空格*/
                    System.out.print("      ");
                }    
            for(int j =1; j<=i; j++){
                int re = j*i;
                if (re<10){
                    System.out.print(j+"×"+i+"= "+re+"  ");
                }else{
                    System.out.print(j+"×"+i+"="+re+"  ");  
                 }
               
            }
        System.out.println();
        }
    }
}

 js版

<script type="text/javascript">
    for(var i=1;i<10;i++){
        for(var j=1;j<=i;j++){
            var re = i * j;
            document.write(re<10?j+'×'+i+'=&nbsp;'+re+'&nbsp;':j+'×'+i+'='+re+'&nbsp;');
        }
    document.write('<br/>');
    }
</script>

 

posted @ 2016-07-11 09:38  如果屈原会编程  阅读(180)  评论(0编辑  收藏  举报