题解 | #对称矩阵#

对称矩阵

https://www.nowcoder.com/practice/ad11ebc8d44842c78bb0bbfb6d07ad7a

#include <bits/stdc++.h>
#define MAX 100
using namespace std;

int main() {
    int n;
    int data[MAX][MAX];
    while (cin >> n) {
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                cin >> data[i][j];

        bool flag = true;
        for (int i = 0; i < n && flag; i++)
            for (int j = 0; j < i && flag; j++) {
                if (data[i][j] != data[j][i])
                    flag = false;
            }
        if (flag)
            cout << "Yes!" << endl;
        else
            cout << "No!" << endl;
    }


}

全部评论

相关推荐

中电45所 测试开发岗 可以解决北京户口,提供员工宿舍,早 8 晚 5(不过一般会加班到7-8点,周六一般也会去,面试官说的) 硕士
点赞 评论 收藏
转发
1 收藏 评论
分享
牛客网
牛客企业服务