• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            腳踏實地

            心 勿噪

            矩陣計算器

            <html>
            <head>
            <title>矩陣計算器 (1.0)</title>
            <meta charset="utf-8">
            <style>
            div#centerDiv 
            {
                width
            :420px;
                margin
            :0 auto;
            }
            input 
            {
                text-align
            :center;
                width
            :100px;
            }
            </style>
            </head>
            <body style="background-color:#999" onload="Start()">
            <div id="centerDiv">
            <h2>矩陣計算器</h2>
            <table  border="1" id="matrixA">
            <th colspan="4">矩陣A</th>
            <tr>
                <td><input class="m00" type="text" value="1"></td>
                <td><input class="m01" type="text" value="0"></td>
                <td><input class="m02" type="text" value="0"></td>
                <td><input class="m03" type="text" value="0"></td>
            </tr>
            <tr>
                <td><input class="m10" type="text" value="0"></td>
                <td><input class="m11" type="text" value="1"></td>
                <td><input class="m12" type="text" value="0"></td>
                <td><input class="m13" type="text" value="0"></td>
            </tr>
            <tr>
                <td><input class="m20" type="text" value="0"></td>
                <td><input class="m21" type="text" value="0"></td>
                <td><input class="m22" type="text" value="1"></td>
                <td><input class="m23" type="text" value="0"></td>
            </tr>
            <tr>
                <td><input class="m30" type="text" value="0"></td>
                <td><input class="m31" type="text" value="0"></td>
                <td><input class="m32" type="text" value="0"></td>
                <td><input class="m33" type="text" value="1"></td>
            </tr>
            </table>

            <style="width:420px; text-align:center;">右乘</p>

            <table  border="1" id="matrixB">
            <th colspan="4">矩陣B</th>
            <tr>
                <td><input class="m00" type="text" value="1"></td>
                <td><input class="m01" type="text" value="0"></td>
                <td><input class="m02" type="text" value="0"></td>
                <td><input class="m03" type="text" value="0"></td>
            </tr>
            <tr>
                <td><input class="m10" type="text" value="0"></td>
                <td><input class="m11" type="text" value="1"></td>
                <td><input class="m12" type="text" value="0"></td>
                <td><input class="m13" type="text" value="0"></td>
            </tr>
            <tr>
                <td><input class="m20" type="text" value="0"></td>
                <td><input class="m21" type="text" value="0"></td>
                <td><input class="m22" type="text" value="1"></td>
                <td><input class="m23" type="text" value="0"></td>
            </tr>
            <tr>
                <td><input class="m30" type="text" value="0"></td>
                <td><input class="m31" type="text" value="0"></td>
                <td><input class="m32" type="text" value="0"></td>
                <td><input class="m33" type="text" value="1"></td>
            </tr>
            </table>

            <div style="margin:0 auto; width:100%; display:block; text-align: center;">
            <div>
            <button id="calc" style="margin:16px; border-radius:2px; font-size:18px;" align="center">  等于  </button>
            </div>
            </div>

            <table  border="1" id="matrixResult">
            <th colspan="4">結(jié)果矩陣</th>
            <tr>
                <td><input class="m00" type="text" value="1" readonly="readonly"></td>
                <td><input class="m01" type="text" value="0" readonly="readonly"></td>
                <td><input class="m02" type="text" value="0" readonly="readonly"></td>
                <td><input class="m03" type="text" value="0" readonly="readonly"></td>
            </tr>
            <tr>
                <td><input class="m10" type="text" value="0" readonly="readonly"></td>
                <td><input class="m11" type="text" value="1" readonly="readonly"></td>
                <td><input class="m12" type="text" value="0" readonly="readonly"></td>
                <td><input class="m13" type="text" value="0" readonly="readonly"></td>
            </tr>
            <tr>
                <td><input class="m20" type="text" value="0" readonly="readonly"></td>
                <td><input class="m21" type="text" value="0" readonly="readonly"></td>
                <td><input class="m22" type="text" value="1" readonly="readonly"></td>
                <td><input class="m23" type="text" value="0" readonly="readonly"></td>
            </tr>
            <tr>
                <td><input class="m30" type="text" value="0" readonly="readonly"></td>
                <td><input class="m31" type="text" value="0" readonly="readonly"></td>
                <td><input class="m32" type="text" value="0" readonly="readonly"></td>
                <td><input class="m33" type="text" value="1" readonly="readonly"></td>
            </tr>
            </table>

            </div>

            <script>
                
                
            function Assert(e, msg) {
                    
            if (!e) {
                        alert(msg);
                    }
                }
                
                
            function GetMatrixValue(table, row, col) {
                    Assert (row 
            <= 4 && row >= 1"matrix row index invalid.");
                    Assert (col 
            <= 4 && col >= 1"matrix col index invalid.");
                    
                    
            var className = "m" + (row - 1)
                    className 
            += (col - 1)
                    
            var c = table.getElementsByClassName(className);
                    
            if (c.length > 0) {
                        
            return c[0].value;
                    }
                    
            return null;
                }
                
                
            function SetMatrixValue(table, row, col, value) {
                    Assert (row 
            <= 4 && row >= 1"matrix row index invalid.");
                    Assert (col 
            <= 4 && col >= 1"matrix col index invalid.");
                    
                    
            var className = "m" + (row - 1)
                    className 
            += (col - 1)
                    
            var c = table.getElementsByClassName(className);
                    
            if (c.length > 0) {
                        c[
            0].value = value;
                    }
                }
                
                
            function UnitMatrix(table) {
                    
            for  (var i = 1; i <= 4++i) {
                        
            for (var j = 1; j <= 4++j) {
                            
            if (i === j) {
                                SetMatrixValue(table, i, j, 
            1);
                            }
                            
            else {
                                SetMatrixValue(table, i, j, 
            0);
                            }
                        }
                    }
                }
                
                
            function ClearMatrix(table) {
                    
            for  (var i = 1; i <= 4++i) {
                        
            for (var j = 1; j <= 4++j) {
                            SetMatrixValue(table, i, j, 
            0);
                        }
                    }
                }

                
            function MatrixMul(matrixA, matrixB, matrixResult) {
                    
            var a, b, r, t;
                    ClearMatrix(matrixResult);
                    
            for  (var i = 1; i <= 4++i) {
                        
            for (var j = 1; j <= 4++j) {
                            
            for (var k = 1; k <= 4++k) {
                                a 
            = GetMatrixValue(matrixA, i, k);
                                b 
            = GetMatrixValue(matrixB, j, k);
                                
            if (isNaN(a) || isNaN(b)) {
                                    
            if (b === "0" || a === "0") {
                                        r 
            = 0;
                                    }
            else {
                                        
            if (a === "1" || b === "1") {
                                            
            if (a === "1")
                                                r 
            = b;
                                            
            else
                                                r 
            = a;
                                        }
            else {
                                            r 
            = "(" + a + "*" + b + ")";
                                        }
                                    }
                                }
            else {
                                    r 
            = Number(a) * Number(b);
                                }
                                t 
            = GetMatrixValue(matrixResult, i, j);
                                
            if (isNaN(t) || isNaN(r)) {
                                    
            if (t === "0" || r === 0) {
                                        
            if (t === "0")
                                            SetMatrixValue(matrixResult, i, j, r);
                                        
            else
                                            SetMatrixValue(matrixResult, i, j, t);
                                    }
                                    
            else {
                                        SetMatrixValue(matrixResult, i, j, t 
            + "+" + r);
                                    }
                                }
                                
            else {
                                    SetMatrixValue(matrixResult, i, j, Number(t) 
            + r);
                                }
                            }
                        }
                    }
                }

                
            function Start() {
                    
            var matrixA = document.getElementById("matrixA");
                    
            var matrixB = document.getElementById("matrixB");
                    
            var matrixResult = document.getElementById("matrixResult");
                    
                    
            var button = document.getElementById("calc");
                    
            if (button) {
                        button.onclick 
            = function() {
                            MatrixMul(matrixA, matrixB, matrixResult);
                        }
                    }
                }
            </script>
            </body>
            </html>

            posted on 2017-01-19 23:36 LSH 閱讀(608) 評論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            国产精品美女久久久网AV| 久久久久久久久久久| 久久久青草青青亚洲国产免观| 69久久精品无码一区二区| 国产精品久久久久aaaa| 欧美国产成人久久精品| 天天躁日日躁狠狠久久 | 国产成人久久777777| 久久婷婷人人澡人人| 国产成年无码久久久久毛片| 激情久久久久久久久久| 色偷偷偷久久伊人大杳蕉| 91精品国产91久久| 久久午夜羞羞影院免费观看| 国产亚洲精久久久久久无码AV| 777午夜精品久久av蜜臀| 精品久久久久久无码中文野结衣 | 国产精品成人99久久久久 | 99麻豆久久久国产精品免费| 亚州日韩精品专区久久久| 国产精品久久毛片完整版| 久久www免费人成看片| 久久国产香蕉视频| 精品综合久久久久久97超人| 麻豆精品久久久久久久99蜜桃| 精品国产91久久久久久久a| 精品久久777| 久久99国产精一区二区三区| 少妇高潮惨叫久久久久久| 久久天天躁夜夜躁狠狠| 四虎久久影院| 色综合久久久久综合99| 日批日出水久久亚洲精品tv| 国产高清美女一级a毛片久久w| 国内精品久久久久| 伊人色综合久久天天| 国产精品一久久香蕉产线看| 999久久久免费精品国产| 97久久超碰成人精品网站| 久久九九青青国产精品| 久久亚洲精品视频|