vect0r
2023-08-18 11:25:46
发布于:广东
91阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> xorAndNegateMatrix(vector<vector<int>>& matrix1, vector<vector<int>>& matrix2) {
int n = matrix1.size();
int m = matrix1[0].size();
vector<vector<int>> result(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int val = matrix1[i][j] ^ matrix2[i][j];
result[i][j] = ~val;
}
}return result;
}int main() {
int n, m;
cin>>n>>m;
vector<vector<int>> matrix1(n, vector<int>(m));
vector<vector<int>> matrix2(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> matrix1[i][j];
}
}for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> matrix2[i][j];
}
}vector<vector<int>> result = xorAndNegateMatrix(matrix1, matrix2);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << result[i][j] << " ";
}cout << endl;
}
}
这里空空如也
有帮助,赞一个