题解 | #图像相似度#
图像相似度
https://www.nowcoder.com/practice/f2952ee3bb5c48a9be6c261e29dd1092
#include <iostream> #include<iomanip> using namespace std; int main() { int a, b, c[100][100], d[100][100], count = 0, sum; cin >> a >> b; sum = a * b; for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { cin >> c[i][j]; } } for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { cin >> d[i][j]; } } for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { if (c[i][j] == d[i][j]) count++; } } cout << setiosflags(ios::fixed) << setprecision(2) << 100.0 * count / sum; }