手敲键盘都敲废了
2023-12-24 13:45:24
发布于:广东
159阅读
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;
}
}
全部评论 1
最好是
2024-04-20 来自 广东
0
有帮助,赞一个