• <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   管理


            亚洲国产精品综合久久一线| 国产偷久久久精品专区| 国产福利电影一区二区三区久久老子无码午夜伦不 | 久久丝袜精品中文字幕| 欧美日韩久久中文字幕| 97精品伊人久久大香线蕉app| 久久综合狠狠综合久久激情 | 久久人人爽人人爽AV片| 性做久久久久久久| 久久er国产精品免费观看8| 久久99久久99精品免视看动漫| 色综合久久天天综合| 久久精品一本到99热免费| 国产ww久久久久久久久久| 日韩精品久久久久久久电影蜜臀| 精品99久久aaa一级毛片| 久久亚洲精品中文字幕| 伊人久久大香线蕉综合5g| 久久九九有精品国产23百花影院| 久久天天躁狠狠躁夜夜2020一 | 国产欧美久久久精品| 中文字幕精品久久久久人妻| 青青青青久久精品国产 | 国产精品99久久久久久董美香| 久久久亚洲欧洲日产国码是AV| 国产精品99久久久久久猫咪| 久久免费的精品国产V∧| 久久无码高潮喷水| 无码国内精品久久人妻麻豆按摩 | 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 久久精品人人做人人妻人人玩| 一本大道久久东京热无码AV| 久久久久免费精品国产| 久久久久无码精品国产| 久久久精品久久久久影院| 国产成人香蕉久久久久| 亚洲一本综合久久| 久久久精品免费国产四虎| 精品免费tv久久久久久久| 99久久国语露脸精品国产| 狼狼综合久久久久综合网|