for information on how your program can#include "stdafx.h"using namespace std; void main() { int i,j,num; double str[11];//11个特征值查询模型 double ds[11];//数据库模型的特征值 double same[400]; //相似度 double

来源:学生作业帮助网 编辑:作业帮 时间:2024/07/10 14:26:23
for information on how your program can#include "stdafx.h"using namespace std; void main()  {      int  i,j,num;    double str[11];//11个特征值查询模型 double ds[11];//数据库模型的特征值 double same[400]; //相似度 double
xXsFWrc'̴Q$Yrd,Ag+o@[Rځ1GHCg,VZٱl9LjoJNX6iг߲suuP;:Z64 q O\nl|$XY7owqIIs".ôhnmk^gF~d'EA[wkH@s\G;m[.ot JomBCsix+^!`rpGZepbsϺYБl&&?|Ԫ8%`TJ0s'9~6'X|쑷:{wsCpQV?۹x֒{gr|47?fO=;t m17{ܟ g)uzmTRubX=3( dDtNʹ31,ǝ ,L-w1ώ13I?0Xiث*>麰d*B蔦h/']Q {Gf"[B>p\,BY Bf,) q9HNQńTvY*OA57Oow%D/ Yvgrʰ9^hh zs ,RXm1Էd)47͸9:#;wuwȽ3^~R0rzuCu?)qs^ M%݋ `G3# 8 (Cgگ;Nu{\ƑQf8@Bu$`0b)Zхhz3r 7"g 7Ğ*fb՜LvҦV.-SuTG5rLm19]𻵜v U݃kBx{ HU)4*߀!|܎;~LmHΎ+L0V4˽̔"RRsO.ȋkELղTTSVsN!4ĵ8F3K:|OTJk4~Զ__YrɿٺQsタur;|z j jsNcjscߩ(ьU-T[yJ_$ Qqyi)VLܼ-GNW2Ü.fe=VYq]T1g Q I'$ꤕUB68Ƭնy? nn%okDÒn>ln^O&?&g{Sb:2O,dAp2 _C*nsݓεfcJ '\ gEY<4 ^ =۹,==i %vMr"mky!KnGd%=

for information on how your program can#include "stdafx.h"using namespace std; void main() { int i,j,num; double str[11];//11个特征值查询模型 double ds[11];//数据库模型的特征值 double same[400]; //相似度 double
for information on how your program can
#include "stdafx.h"
using namespace std;
 void main() 

    int  i,j,num;
    double str[11];//11个特征值查询模型
 double ds[11];//数据库模型的特征值
 double same[400]; //相似度
 double sum;
 tot:
 CString f_name,m_path,m_name;
 cout<<"选择特征文件 ";
 system("pause");
 CFileDialog dlg(true,NULL,NULL,OFN_HIDEREADONLY,_T("模型特征向量文件(*.txt)|*.txt||"));
 
 if(dlg.DoModal()==IDOK)
    {
        m_path=dlg.GetPathName();
  cout<<m_path<<endl;
  m_name=dlg.GetFileName();
  
    }//if(dlg.DoModal()==IDOK)
  ifstream f;
  f.open(m_path,ios::in);
   if f.is_open())
    {
  /*文件不存在,操作失败*/
        AfxMessageBox(_T("文件"+m_path+"不存在!"));
       goto tot;
    }
     for (i=0;i<11;i++)
    {
        f>>str[i];
 // cout<<str[i]<<"  ";
  }
 f.clear();
    f.close();
 cout<<"\n输入计算相似度模型的个数  ";
 cin>>num;
 char s[256];
  char t[2]; 
 
 for(j=1;j<=num;j++)
 {
  
    strcpy(s,"E:\\cut\\off\\");
    sprintf(t,"%d",j);  
    strcat(t,".txt");
    strcat(s,t);
    f_name=s;
    f.open(f_name,ios::in);
       if f.is_open())
       {
   /*文件不存在,操作失败*/
   AfxMessageBox(_T("文件"+f_name+"不存在"));
   return;    
    }
   for (i=0;i<11;i++)
   {
    f>>ds[i];
   // cout<<"["<<i<<"]"<<ds[i]<<endl;
      }
   sum=0.0;
   for(i=0;i<11;i++)
   {
    sum+=(str[i]-ds[i])*(str[i]-ds[i]);
   }
   same[j]=sqrt(sum);
   //cout<<"same["<<j<<"]="<<same[j]<<endl;
   f.clear();
    f.close();
 }//for(j=1;j<=num;j++)
 //保存文件 
 char tt[2];  
 sprintf(tt,"%d",num);  
 FILE *fp;
 char fname[32];/*文件名*/
 strcpy(fname,"1-"); 
 strcat(fname,tt);
 strcat(fname,".txt");
 fp=fopen(fname,"w+");
 for(i=1;i<=num;i++)
 {
  fprintf(fp,"%f",same[i]);
  fprintf(fp,"\n");
 }
 
 fclose(fp);
  
}
运行首先出现第一张图,忽略后能运行.执行完了跳出第二三张图,忽略后结束.


for information on how your program can#include "stdafx.h"using namespace std; void main() { int i,j,num; double str[11];//11个特征值查询模型 double ds[11];//数据库模型的特征值 double same[400]; //相似度 double
char t[2]; 只能放1个字符,另一个用于字符串结尾符号.你却用它
sprintf(t, "%d",j);
strcat(t,".txt");
你要把它加大才行.例如声明为 char t[80]; 或 char t[200];

tt 也是同样问题.你要把它加大才行.

改正后再查 第一个问题 (在第14行)