题解 | #矩阵相等判定#
矩阵相等判定
https://www.nowcoder.com/practice/2f058b1e89ae43f7ab650c0fd0b71fa8
小白尝试,还望大佬指点
#include <iostream> using namespace std; int main() { int x, y, b; int arr1[50][50]; int arr2[50][50]; cin >> x >> y; //输入数组arr1 for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { cin >> arr1[i][j]; } } //数组arr2 for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { cin >> arr2[i][j]; } } //遍历数组进行判断 for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { if (arr1[i][j] == arr2[i][j]) { b = 0; } else { b = 1; } } } //输出结果 if(b==0) { cout<<"Yes"; }else{ cout<<"No"; } }