题解 | #图像相似度#
图像相似度
https://www.nowcoder.com/practice/f2952ee3bb5c48a9be6c261e29dd1092
#include <stdio.h> int main() { int row = 0; int col = 0; while (scanf("%d %d", &row, &col) != EOF) { int arr1[100][100] = {0}; int arr2[100][100] = {0}; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { scanf("%d",arr1[i] + j); } } for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { scanf("%d",arr2[i] + j); } } float ResemblePointCount = 0.0; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { if (arr1[i][j] == arr2[i][j]) { ResemblePointCount++; } } } float percentage = (ResemblePointCount / (row *col)) * 100.00; printf("%.2f",percentage); } return 0; }