四重for,AC了
2025-07-12 14:18:07
发布于:浙江
0阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
vector<string>A,B;
for (int i=0;i<n;i++){
string s;
cin>>s;
A.push_back(s);
}for (int i=0;i<n;i++){
string s;
cin>>s;
B.push_back(s);
}
int count=0;
for (int x=0;x<=n-m;x++){
for (int y=0;y<=n-m;y++){
int diff=0;
for (int i=0;i<m;i++){
for (int j=0;j<m;j++){
if (A[x + i][y + j] != B[x + i][y + j]){
diff++;
if (diff>1)break;
}
}
if (diff>1) break;
}
if (diff==1) count++;
}
}
cout<<count;
return 0;
}
这里空空如也
有帮助,赞一个