九九乘法表
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+'= '+re+' ':j+'×'+i+'='+re+' '); } document.write('<br/>'); } </script>