题解 | #图像相似度#
图像相似度
https://www.nowcoder.com/practice/f2952ee3bb5c48a9be6c261e29dd1092
#include <stdio.h> int main() { short m,n; scanf("%hd%hd",&m,&n); short arr[m][n]; short arr2[m][n]; short i = 0; short j = 0; for(i = 0;i < m;i++) { for(j = 0;j < n;j++) { scanf("%hd",&arr[i][j]); } } for(i = 0;i < m;i++) { for(j = 0;j < n;j++) { scanf("%hd",&arr2[i][j]); } } short mul = m * n; short sum = 0; for(i = 0;i < m;i++) { for(j = 0;j < n;j++) { if(arr[i][j] == arr2[i][j]) sum += 1; } } printf("%.2lf\n",sum/(double)mul*100); return 0; }