课评: 转出学生归档(王子墨/张立坤/黄俊博)+ 周四班级总结 + 新生章梓皓档案 + C++示例代码
This commit is contained in:
35
C++代码/CSP04/03-二维数组/图像相似度.cpp
Normal file
35
C++代码/CSP04/03-二维数组/图像相似度.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define endl '\n'
|
||||
using namespace std;
|
||||
|
||||
int n, m;
|
||||
int a[110][110];
|
||||
int b[110][110];
|
||||
|
||||
int main(){
|
||||
cin >> n >> m;
|
||||
for(int i = 1; i <= n; i++){
|
||||
for(int j = 1; j <= m; j++){
|
||||
cin >> a[i][j];
|
||||
}
|
||||
}
|
||||
for(int i = 1; i <= n; i++){
|
||||
for(int j = 1; j <= m; j++){
|
||||
cin >> b[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
int cnt = 0;
|
||||
for(int i = 1; i <= n; i++){
|
||||
for(int j = 1; j <= m; j++){
|
||||
if(a[i][j] == b[i][j]){
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << fixed << setprecision(2);
|
||||
cout << 100.0 * cnt / (n * m) ;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user