题解-矩阵相加
2025-12-29 20:39:49
发布于:广东
9阅读
0回复
0点赞
思路:没什么好讲的,干就完了
-----------分割线-------------
C++AC代码:
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int arr[a+1][b+1],brr[a+1][b+1];
for(int i=1;i<=a;i++){
for(int j=1;j<=b;j++){
cin>>arr[i][j];
}
}
for(int m=1;m<=a;m++){
for(int n=1;n<=b;n++){
cin>>brr[m][n];
}
}
for(int k=1;k<=a;k++){
for(int l=1;l<=b;l++){
cout<<arr[k][l]+brr[k][l]<<" ";
}
cout<<endl;
}
return 0;
}
掐指一算,时间复杂度是O(N)^2
相关内容:https://www.acgo.cn/problemset/info/79411?questionCollectionId=12515
https://www.acgo.cn/problemset/info/79412?questionCollectionId=12515
这里空空如也







有帮助,赞一个