中断test dword ptr [eax],eax ; probe page.求看程序很短

C++语言 码拜 9年前 (2016-04-24) 2327次浏览
#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;
min=0.0;
for(i=0;i<N2;i++)
{
pv=0L;
for(j=0;j<N1;j++)
{
temp=0.0;
for(k=0;k<128;k++)
temp+=(double)pow((double)(feature1[px+k]-feature2[pv+k]),(int)2);
temp/=(float)128;
if((i==0)||(temp<min))
{
min=temp;
t[i]=int(j);
}
pv+=128;
}
px+=128;
printf(“%d\n”,t[i]);
}
free(feature1);
free(feature2);

}
解决方案

100

#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 t[N2];
int main() {
    int *feature1;
    int *feature2;
    int i,j,k,pv,px;
    double min;
    double temp;
    //定义文件指针
    FILE * fp1;
    FILE * fp2;
    feature1=(int*)calloc(N1*128,sizeof(int));
    if (NULL==feature1) {
        printf("\nCan"t calloc(%d,%d)\n",N1*128,sizeof(int));
        exit(0);
    }
    feature2=(int*)calloc(N2*128,sizeof(int));
    if (NULL==feature2) {
        printf("\nCan"t calloc(%d,%d)\n",N2*128,sizeof(int));
        exit(0);
    }
    //假如文件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);
    fclose(fp1);
    fclose(fp2);
    //文件打开成功
    px=0L;
    min=0.0;
    for(i=0;i<N2;i++) {
        pv=0L;
        for(j=0;j<N1;j++) {
            temp=0.0;
            for(k=0;k<128;k++) {
                temp+=pow((double)(feature1[pv+k]-feature2[px+k]),2.0);
            }
            temp/=128.0;
            if((i==0)||(temp<min)) {
                min=temp;
                t[i]=j;
            }
            pv+=128;
        }
        px+=128;
        printf("i,t[i]:%d,%d\n",i,t[i]);
    }
    free(feature1);
    free(feature2);
}

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明中断test dword ptr [eax],eax ; probe page.求看程序很短
喜欢 (0)
[1034331897@qq.com]
分享 (0)