题解 | 图像相似度
图像相似度
https://www.nowcoder.com/practice/f2952ee3bb5c48a9be6c261e29dd1092
#include <stdio.h> int main() { int m,n; int count = 0; scanf("%d %d",&m,&n); int arr1[100][100] = {0}; int arr2[100][100] = {0}; for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { scanf("%d",&arr1[i][j]); } } for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { scanf("%d",&arr2[i][j]); } } for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { if(arr1[i][j] == arr2[i][j]) { count++; } } } printf("%.2f",count/((float)m*(float)n) * 100); return 0; }
我直接七八个for循环搞定