题解 | #矩阵元素相乘#

矩阵元素相乘

https://www.nowcoder.com/practice/935fbb71542345ef87a7acc190e2577b?tpId=182&tqId=34667&rp=1&ru=/exam/oj&qru=/exam/oj&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E5%2590%258D%25E4%25BC%2581%25E7%259C%259F%25E9%25A2%2598%26topicId%3D182&difficulty=undefined&judgeStatus=undefined&tags=&title=

const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void async function () {
    // Write your code here
    while(line = await readline()){
        line0 = line.split(' ');
        line0Int = line0.map(Number);
        linen = new Array;
        for(let i=0; i<line0Int[0]; i++){
            matrixlinen = await readline();
            matrixlinens = matrixlinen.split(' ');
            matrixlinensInt = matrixlinens.map(Number);
            linen.push(matrixlinensInt);
        }
        matrix = linen;
        let max =0;
        for(let i=0; i<line0Int[0]; i++){
            for(let j=0; j<line0Int[1]; j++){
                let xijm = 1;
                for(let m=0; m<line0Int[1]; m++){
                    if(m!=j){
                        xijm *= matrix[i][m];
                    }
                }
                for(let n=0; n<line0Int[0]; n++){
                    if(n!=i){
                        xijm *= matrix[n][j];
                    }

                }
                result = xijm;
                max = Math.max(max, result);
            } 
        }
        console.log(max);
    }
}()

全部评论

相关推荐

10-09 09:39
门头沟学院 C++
HHHHaos:这也太虚了,工资就一半是真的
点赞 评论 收藏
分享
贺兰星辰:不要漏个人信息,除了简历模板不太好以外你这个个人简介是不是太夸大了...
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务