• javascript实现九九乘法表


     左下角

     1 function leftdown(){
     2         document.write("<table>");
     3         for(var i=1;i<=9;i++)
     4             {   
     5                  document.writeln("<tr>");
     6 
     7                 for(var j=1;j<=i;j++)
     8                 {
     9                     var m=i*j;
    10                     document.write("<td>"+j+"*"+i+"="+m+"</td>");
    11                 }document.write("</tr>");
    12             }
    13             document.write("</table>");
    14 
    15     }
    16 
    17     leftdown();
    18     document.write("</br>");
    View Code

    左上角

     1 function lefttop(){
     2         document.writeln("<table>");
     3         for(var i=1;i<=9;i++)
     4             {document.writeln("<tr>");
     5                 for(var j=i;j<=9;j++)
     6                 {
     7                     var m=i*j;
     8                     document.write("<td>"+i+"*"+j+"="+m+"</td> ");
     9                 }document.write("</tr>");
    10             }document.write("</table>");
    11 
    12     }
    13     lefttop();
    14     document.write("</br>");
    View Code

    右下角

     1 function rightdown(){
     2                 document.write("<table>");
     3                 for(var i=1;i<=9;i++)
     4 
     5                         {
     6                                 document.writeln("<tr>");
     7                                 for(var k=1;k<=9-i;k++)
     8                                         {
     9                                                 document.write("<td style='border:none'></td>");
    10 
    11                                         }
    12                                 for(var j=1;j<=9;j++)
    13                                 {
    14                                         if(j>i){
    15                                                 document.write(" ");
    16                                         }
    17                                         else{
    18                                                 var m=i*j;
    19                                         document.write("<td>"+i+"*"+j+"="+m+"</td>");
    20 
    21                                         }
    22 
    23                                 }document.writeln("</tr>");
    24                                 
    25                         }document.writeln("</table>");
    26 
    27         }
    28         rightdown();
    29         document.write("</br>");
    View Code

    右上角

     1 function righttop(){
     2         document.write("<table>");
     3         for(var i=1;i<=9;i++)
     4             {
     5                 document.writeln("<tr>");
     6                 for(var j=1;j<=9;j++)
     7                 {
     8                     
     9                     if(i>j){
    10                         document.write("<td style='border:none'></td>");
    11                     }
    12                     else{
    13                     var m=i*j;
    14                     document.write("<td>"+i+"*"+j+"="+m+"</td>");
    15 
    16                     }
    17         
    18                 }document.writeln("</tr>");
    19                 
    20             }document.writeln("</table>");
    21 
    22     }
    23     righttop();
    24     document.write("</br>");
    View Code
  • 相关阅读:
    [LeetCode]4Sum
    [LeetCode]3Sum
    [LeetCode]Two Sum
    [LeetCode]Maximal Rectangle
    [LeetCode]Largest Rectangle in Histogram
    [LeetCode]Sudoku Solver
    [LeetCode]Group Anagrams
    jQuery验证控件jquery.validate.js使用说明+中文API
    js操作cookie,实现登录密码保存
    Java中getResourceAsStream的用法
  • 原文地址:https://www.cnblogs.com/WhatTTEver/p/6898639.html
Copyright © 2020-2023  润新知