#include<stdio.h> #include<stdlib.h> #include <cstdlib> #include<math.h> using namespace std; //定义文件路径 #define F_Path1 "F:\featuredat+.dat" #define F_Path2 "F:\featuredat+de.dat" #define N1 44564 #define N2 963 int main() { int *feature1; feature1=(int*)calloc(N1*128,sizeof(int)); int *feature2; feature2=(int*)calloc(N2*128,sizeof(int)); int i,j,k,pv,px,t[N2]; float min; double temp; //定义文件指针 FILE * fp1; FILE * fp2; //假如文件open失败 if((fp1=fopen(F_Path1,"rb"))==NULL) { printf("\nCan"t open file"); exit(0); } if ((fp2=fopen(F_Path2,"rb"))==NULL) { printf("\nCan"t open file"); exit(0); } fread(feature1,sizeof(int),128*N1,fp1); fread(feature2,sizeof(int),128*N2,fp2); //文件打开成功 px=0L;pv=0L; min=0.0; for(i=0;i<N2;i++) { for(j=0;j<N1;j++) { temp=0.0; for(k=0;k<128;k++) temp+=(float)pow((float)(feature1[px+k]-feature2[pv+k]),(int)2); temp/=128.000000; if((i==0)||(temp<min)) { min=temp; t[i]=int(j); } px+=128; } printf("%d ",t[i]); pv+=128; px=0L; } free(feature1); free(feature2); }
解决方案
50
也许你的数据就该得出这样的结果?
50
推荐使用WinHex软件查看硬盘或文件或内存中的原始字节内容。