我编了一段程序
程序中有两个类,每个类中有几个函数
程序中不知哪有问题
我逐步执行
运行几个函数都是对的
但当我运行到一个函数时
一进入函数体就出错
要我告诉chkstk.asm的路径,也要我告诉printf.c的位置
我点取消
说什么“Unhandled exception in test2.exe:0xC00000FD: Stack Overflow”
另外,为什么我的VC编译时找不这个路径,而在我们同学的机器上就能找到这个文件呢? 另外,能不能推荐一下深入VC调试的书或电子文档!
 非常感谢! 
哪位大侠知道如何解决这一问题
请帮一下小弟
感谢了!

解决方案 »

  1.   

    是不是printf的参数个数不对,或者类型不对
      

  2.   

    首先庆祝一下这是我第一次在CSDN上看到五个星星的顶尖级高手,心情很激动
    不把源代码贴出来,说什么都没用!VC提示信息仅供参考,也不可迷信啊!
      

  3.   

    首先庆祝一下这是我第一次在CSDN上看到五个星星的顶尖级高手,心情很激动
    不把源代码贴出来,说什么都没用!VC提示信息仅供参考,也不可迷信啊!同感, i am 也是第一次。
      

  4.   

    源代码如下:
    一运行到exercise::mat()函数就出错
    要我告诉chkstk.asm的路径,也要我告诉printf.c的位置
    我点取消
    说什么“Unhandled exception in test2.exe:0xC00000FD: Stack Overflow”
    另外,为什么我的VC编译时找不这个路径,而在我们同学的机器上就能找到这个文件呢?
    请各位大侠指点小弟了
    小弟将把自己的全部家产(100)给解决这一问题的高手
    大家帮我分析一下吧
    另外,能不能推荐一下深入VC调试的书或电子文档!
    非常感谢! 下面的全部源代码:#include <iostream.h>
    #include <math.h>
    #include <fstream.h>
    #include <conio.h>
    #include <iomanip.h>
    #include <string.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <time.h>
    #include <malloc.h>
    #include <string>const int M=4;
    const int N=24;
    const int P=24;
    int T; //T为输入输出训练样本的组数
    int row;        //row为jacobi矩阵的行数  
    const int Q=M*N+N*P+N+P;  //Jacobi矩阵的列数
    const  double namdk=0.01;   //λk
    double errorsum=0.0;    //误差和
    double TTL;
    int brinv(double a[], int n);class exerise
    {
    //  friend  class  predict;
    public:
    exerise();
       void  initiate();
       void  caculatex(float *p3);
    //    void  caculatee(float  *p3);
       void  caculatedwin();
       void  caculatedwout();
       void  caculatefazhiout();
       void  caculatefazhimid();
       void  Output(float *out);
       void  mat(); //求出搜索方向d
       int  getT();    //取得T的大小,其中T为输入输出训练样本的组数
       double  judge(double *p4);
    public:
    double  v,bian, lv ;
    public:
    double *m; //矩阵m存放输入层的数据(有M*T个元素)
    double Dfazhimid[N],Dfazhiout[P];
    double (*xoutd)[P],(*xout)[P],(*xind)[N],(*xin)[N];
    double emid[N],eout[P];
    double Dmid[M][N],Dout[N][P];
    double win[M][N],wout[N][P],fazhimid[N],fazhiout[P];
    double dxz[Q]; //包含输入、输出权值,输入、输出阈值的修正值的矩阵
    double *jaco;
    double (*jc)[Q];
    double (*errf); //f即期望输出与网络输出的差
    double (*tp)[Q];
    };
    //***************************************************************************************
    //给变量赋初值
    //*************************************************************************************** void exerise::initiate()  //exerise类的初始化
    {     
    //   T=exerise::getT();     //取得T的大小,其中T为输入输出训练样本的组数
      srand((unsigned)time(NULL));
       for(int i=0;i<N;i++)
    {
    for(int j=0;j<M;j++)
    {   
      win[j][i]=rand()*0.1/RAND_MAX-0.05;     //输入层权矩阵
    Dmid[j][i]=0; //输入层权矩阵的修正矩阵
    }
    fazhimid[i]=0.5; //中间层的阈值
    Dfazhimid[i]=0; //中间层的阈值误差
    // emid[i]=0;
    }
           
      for(int p=0;p<P;p++)
    {
    for(int q=0;q<N;q++)
    {
    wout[q][p]=rand()*0.5/RAND_MAX-0.25; //输出层权矩阵
    Dout[q][p]=0; //输出层权矩阵的修正矩阵
    }
    fazhiout[p]=0; //输出层的阈值
    Dfazhiout[p]=0; //输出层的阈值误差
    // eout[p]=0;
    }
    /*
    lv=0.5;
    bian=0.5;
    v=0.2;
    */
    }

    //***************************************************************************************
    //先通过的方法将两天10个相应的天气值(包括前一天和前一周的相应的一天)赋给相应的变量
    //***************************************************************************************
    exerise::exerise()
    {
    T=exerise::getT();
    m=new double[T*M];
    xin=new double[T][N];
    xind=new double[T][N];
    xout=new double[T][P];
    xoutd=new double[T][P];
    double zjj,*p5;
    p5=&zjj;
    int i=0;
    FILE *fp;
    fp=fopen("tradata.txt","r"); //打开存储输入训练数据的文件(数据个数发须为M的整数倍)
    if(fp==NULL)
    {
    cout<<"\a错误!,不能打开traindata.txt文件";
    exit(1);
    }
    while(!feof(fp))
    {
    float temp;
    fscanf(fp,"%f",&temp);
    m[i]=temp;
    i++;
    }
    if((i-1)%M!=0) cout<<"\a Sorry,the data that you have sent don't match with input node number!"; //输入的训练数据不是输入层结点的整数倍
    T=(i-1)/M;  //T为输入输出训练样本的组数
    fclose(fp);
    row=T*P;
    // xout=new double[T][P];   //xout的初始化,xout为输出层的净输出
    for(int j=0;j<T;j++)
    for(int k=0;k<P;k++)
    xout[j][k]=0;
    }
    //***************************************************************************************
    //***************************************************************************************
    //将已赋值的气象因素下的实际负荷值作为标准输出,从而调整相应的权值和阀门值,其中P2即是该
    //标准负荷值
    //***************************************************************************************
    void exerise::Output(float *out)
    {
    // out=new float[T*P];
    int i=0;
    FILE *fp;
    fp=fopen("docu.txt","r"); //打开存储期望输出数据的文件
    if(fp==NULL)
    {
    cout<<"\a can't open desired output data document.";
    exit(1);
    }
    while(!feof(fp))
    {  
    float temp;
    fscanf(fp,"%f",&out[i]);
    i++;
    }
    i--;
    cout<<i;
    if(i%P!=0&&i/P!=T) cout<<"\a Sorry,the data that you have sent don't match with output node number!"; //输入的训练数据不是输出层结点的整数倍
    double Max=0,Min=0.0;
        TTL=0.0;
    for(int j=0;j<i;j++)
    {
      if(Min>out[j])Min=out[j];
      if(Max<out[j])Max=out[j];
      TTL+=out[j];
    }
    fclose(fp);
    TTL=TTL/i;
    for(j=0;j<i;j++)
          out[j]=out[j]/TTL;
     
    for(j=0;j<M*T;j++)
    m[j]=m[j]/TTL;
    }
    //****************************************************************************************************************
    //取得T的大小(其中T为输入输出训练样本的组数)
    //**************************************************************************************************************** int exerise::getT()
    {
    int i=0;
    FILE *fp;
    fp=fopen("tradata.txt","r"); //打开存储输入训练数据的文件
    if(fp==NULL)
    {
    cout<<"\a can't open traindata.txt.";
    exit(1);
    }
    while(!feof(fp))
    {
    float temp;
    fscanf(fp,"%f",&temp);
    i++;
    }
    cout<<i-1;
    if((i-1)%M!=0) cout<<"\a Sorry,the data that you have sent don't match with input node number!"; //输入的训练数据不是输入层结点的整数倍
    T=(i-1)/M;  //T为输入输出训练样本的组数
    fclose(fp);
    return T;
    }
      

  5.   

    void exerise::mat()   //求出搜索方向d
    {
    int i,j,k,l;
    int u=0;  //u为jaco矩阵中的元素的位置
        int S=Q*T*P;   //Jacobi矩阵的元素的个数
    jaco=new double[S];  //一维动态数组jaco的声明
    for(k=0;k<T;k++)    //jacobi矩阵的生成 (一维)
    {
    for(j=0;j<P;j++)
    {
    double pout[N][P];  //暂时存放delta(jk)矩阵
    double pfz[P];
      for(l=0;l<N;l++)  //偏f偏输出层权矩阵
       {   
     for(i=0;i<P;i++)
       {
        double temp2;
    if(j==i) temp2=xind[k][l];  
    else temp2=0;
    double temp1=1.0/2*exp(-1.0/2*xout[k][i])/(1+exp(-1.0/2*xout[k][i]))/(1+exp(-1.0/2*xout[k][i]));
    jaco[u]=temp1*temp2;
    pout[l][i]=temp1*temp2;
    u++;
    }
       }
       for(l=0;l<M;l++)       //计算偏f偏输入层权矩阵
       {
            for(i=0;i<N;i++)
       {
         double temp2=0.0;
       double temp1=exp(-1.0/2*xin[k][i])/(1+exp(-1.0/2*xin[k][i]))/(1+exp(-1.0/2*xin[k][i]));
    for(int k1=0;k1<P;k1++)
    {
    temp2=temp2+wout[i][k1]*pout[i][k1];
    }
    jaco[u]=temp1*temp2*m[M*k+l];
    u++;
    }
                       }    for(l=0;l<P;l++)      //计算偏f偏输出阈值矩阵
       {
    double temp2;
    if(l=j) temp2=-1;
    else temp2=0;
        double temp1=1.0/2*exp(-1.0/2*xout[k][l])/(1+exp(-1.0/2*xout[k][l]))/(1+exp(-1.0/2*xout[k][l]));
    jaco[u]=temp1*temp2;
    pfz[l]=temp1*temp2;
    u++;
       }    for(l=0;l<N;l++)    //计算偏f偏输入阈值矩阵
       {
        double temp2=0;
       double temp1=exp(-1.0/2*xin[k][i])/(1+exp(-1.0/2*xin[k][i]))/(1+exp(-1.0/2*xin[k][i]));
    for(int k1=0;k1<P;k1++)
    {
    temp2=temp2+wout[i][k1]*pfz[k1];
    }
    jaco[u]=temp1*temp2*(-1);
    u++;
       }
       }
    }   //矩阵转化(从一维到2维) 
     u=0;
         jc=new double[row][Q];
     for(i=0;i<row;i++)
      for(j=0;j<Q;j++)
      {
           jc[i][j]=jaco[u];
      u++;
      }
     //矩阵相乘 并转化为一维
    double tmp[Q][Q];
    double tmp1[Q*Q];
    int b1=0;
        for(i=0;i<Q;i++)
    for(j=0;j<Q;j++)
    {
    tmp[i][j]=0;
     for(k=0;k<row;k++)
    {
    tmp[i][j]+=jc[k][i]*jc[k][j];
    tmp1[b1]=tmp[i][j];
    b1++;
    }
    }

    //矩阵求逆 if(brinv(tmp1,Q)==0)  //如果矩阵不能求逆时,使用另一个公式
    {
      for(i=0;i<Q;i++)
      for(j=0;j<row;j++)
      {
      dxz[i]=-jc[j][i]*errf[j];
      }
    }
    else     //如果矩阵的求逆时逆存在,使用另一个公式
    {
    //将
    int c3=0;
    for(i=0;i<Q;i++)
    for(j=0;j<Q;j++)
    {
    tmp[i][j]=tmp1[c3];
    c3++;
    }
    //求d
    tp=new double[row][Q]; //存放
    for(i=0;i<Q;i++)
    for(j=0;j<row;j++)
    {
     tp[i][j]=0;
     for(k=0;k<row;k++)
    {
      tp[i][j]+=tmp[i][k]*jc[j][k];
    }
    }
    for(i=0;i<Q;i++)
    for(j=0;j<row;j++)
    dxz[i]=-tp[i][j]*errf[j];
    }    } //***************************************************************************************
    //向前算出此次的误差值
    //***************************************************************************************
    void exerise::caculatex(float *p3) 
    {
    errf=new double[row];
    int i,j,k;
    int v1=0,v2=0; //v1为期望输出值数组的序号,v2为期望输出与网络输出的差数组的序号
    for(k=0;k<T;k++)
     {
    for(j=0;j<N;j++)
    {
    xin[k][j]=0.0;
    int u=0;
       for(i=0;i<M;i++)
    {
    xin[k][j]=xin[k][j]+m[u]*win[i][j]; //中间隐含层净输入
    u++;
    }
    xin[k][j]=xin[k][j]-fazhimid[j];
    xind[k][j]=2/(1+exp(-1.0/2*xin[k][j]));   //中间隐含层输出

    }//算出中间层XIND的值
    for(int n=0;n<P;n++)
    {
    xout[k][n]=0.0;
    for(int s=0;s<N;s++)
    xout[k][n] = xout[k][n] + xind[k][s]*wout[s][n] ;

    xout[k][n]=xout[k][n]-fazhiout[n];
    xoutd[k][n]=1.0/(1+exp(-1.0/2*xout[k][n]))+0.5;
    errf[v2]=xoutd[k][n]-p3[v2];
    v1++;
    v2++;
    }
    }

    }//算出输出层XOUT的值
      

  6.   

    void exerise::caculatedwout()
    {
    int i=0;
    for(int x=0;x<N;x++)
    {
       for(int y=0;y<P;y++)
       {
    Dout[x][y]=dxz[i]*namdk;
    if(Dout[x][y]>=0) errorsum+=Dout[x][y];
    else errorsum-=Dout[x][y];
    wout[x][y]=wout[x][y]+Dout[x][y]; 
    i++;
       }
    }

    }
    //*****************************************************************************************
    //调整WIN的值(输入层权值)
    //*****************************************************************************************
    void exerise::caculatedwin()
    {
    int x1=N*P;
    for(int i=0;i<M;i++)
    {
    for(int j=0;j<N;j++)
    {
    Dmid[i][j] =dxz[x1]*namdk;
    if(Dmid[i][j]>=0)  errorsum+=Dmid[i][j];
    else errorsum-=Dmid[i][j];
    win[i][j] = win[i][j] + Dmid[i][j]; 
    x1++;
    }
    }
    }
    //*****************************************************************************************
    void exerise::caculatefazhiout(void)    //调整输出层阈值
    {
    int j;
    int x2=N*P+M*N;
    for(j=0;j<P;j++)
    {
    Dfazhiout[j]=dxz[x2]*namdk;
    if(Dfazhiout[j]>=0)  errorsum+=Dfazhiout[j];
    else errorsum-=Dfazhiout[j];
    fazhiout[j]=Dfazhiout[j]+fazhiout[j]; 
    x2++;
    }
    }//调整阀值0
    //******************************************************************************************
    void exerise::caculatefazhimid(void)    //调整输入层阈值
    {
    int j;
    int x3=N*P+M*N+P;
      for(j=0;j<N;j++)
      {
       Dfazhimid[j] =dxz[x3]*namdk;
       if(Dfazhimid[j]>=0) errorsum+=Dfazhimid[j];
       else errorsum-=Dfazhimid[j];
       fazhimid[j] = Dfazhimid[j] + fazhimid[j]; 
       x3++;
      }
    }
    //调整阀值
    //通过不断调整WOUT和WIND来达到训练的目的
    //************************************************************************************************
    //计算总的误差值
    //************************************************************************************************
    /*
    float exerise::judge(float *p4)
    {
    int i;
    float wuchahe = 0.0;
    for(i=0;i<P;i++)
    {
    wuchahe = wuchahe +1.0/2*(*p4 - xoutd[i])*(*p4 - xoutd[i]);
            p4++;
    }
    return wuchahe;
    }
    */

    //*************************************************************************************************************
    //利用已经调整好的系数直接预测明天的负荷
    //*************************************************************************************************************
    class predict
    {
    public:
          void suchu(exerise a);

    private:
    double n[M];
    double xout1[P],xoutd1[P],xind1[N],xin1[N];

    };
    //*************************************************************************************************
    //*************************************************************************************************
    void predict::suchu(exerise a)
    {
    cout<<"请输入前一天及上周同一天的气象值!\n";
    /* for(int i1=0;i1<M;i1++)
    {
    cin>>n[i1];
    n[i1]=n[i1]/TTL;
    }
    */
    FILE *fp;
    fp=fopen("test.txt","r");
    if(fp==NULL)
    {
    cout<<"\a can't open qixiang.txt.";
    exit(1);
    }
       int i1=0;
    while(!feof(fp))
    {
    float temp;
    fscanf(fp,"%f",&temp);
    n[i1]= temp;
    i1++;
    }
    fclose(fp);
    /* for(int i1=0;i1<M;i1++)
    {
    n[i1]=;
    n[i1]=n[i1]/TTL;
    }
    */
    cout<<"96个时段内的负荷预测结果\n";
    for(int i2=0;i2<N;i2++)
    {
                xind1[i2]=0;
    xin1[i2]=0;
    for(int j2=0;j2<M;j2++)
    {
    xin1[i2]+=n[j2]*a.win[j2][i2];
    }
    xind1[i2]= 2/(1 + exp(-1.0/2 * (xin1[i2] -a.fazhimid[i2]))) ;
    }
        
        for(int m=0;m<P;m++)
    {
                xout1[m]=0;
         xoutd1[m]=0;
    for(int k=0;k<N;k++)
    {
      xout1[m] = xout1[m] + xind1[k] * a.wout[k][m] ;
    }  
        xout1[m] = xout1[m] -   a.fazhiout[m];
        xoutd1[m] = 1.0/(1 + exp(-1.0/2 *xout1[m] ) )+ 0.5;
        xoutd1[m]=xoutd1[m]*TTL;
        cout<<"["<<m<<"]";
        cout<< xoutd1[m]<< '\t';
        if(m%4==0){cout<<'\n';}
    }
    }//矩阵求反算法模块
     int brinv(double a[], int n)
      { 
     int *is,*js,i,j,k,l,u,v;
        double d,p;
        is=(int*)malloc(n*sizeof(int));
        js=(int*)malloc(n*sizeof(int));
        for (k=0; k<=n-1; k++)
          { d=0.0;
            for (i=k; i<=n-1; i++)
            for (j=k; j<=n-1; j++)
              { l=i*n+j; p=fabs(a[l]);
                if (p>d) { d=p; is[k]=i; js[k]=j;}
              }
            if (d+1.0==1.0)
              { free(is); free(js); printf("err**not inv\n");
                return(0);
              }
            if (is[k]!=k)
              for (j=0; j<=n-1; j++)
                { u=k*n+j; v=is[k]*n+j;
                  p=a[u]; a[u]=a[v]; a[v]=p;
                }
            if (js[k]!=k)
              for (i=0; i<=n-1; i++)
                { u=i*n+k; v=i*n+js[k];
                  p=a[u]; a[u]=a[v]; a[v]=p;
                }
            l=k*n+k;
            a[l]=1.0/a[l];
            for (j=0; j<=n-1; j++)
              if (j!=k)
                { u=k*n+j; a[u]=a[u]*a[l];}
            for (i=0; i<=n-1; i++)
              if (i!=k)
                for (j=0; j<=n-1; j++)
                  if (j!=k)
                    { u=i*n+j;
                      a[u]=a[u]-a[i*n+k]*a[k*n+j];
                    }
            for (i=0; i<=n-1; i++)
              if (i!=k)
                { u=i*n+k; a[u]=-a[u]*a[l];}
          }
        for (k=n-1; k>=0; k--)
          { if (js[k]!=k)
              for (j=0; j<=n-1; j++)
                { u=k*n+j; v=js[k]*n+j;
                  p=a[u]; a[u]=a[v]; a[v]=p;
                }
            if (is[k]!=k)
              for (i=0; i<=n-1; i++)
                { u=i*n+k; v=i*n+is[k];
                  p=a[u]; a[u]=a[v]; a[v]=p;
                }
          }
        free(is); free(js);
        return(1);
      }

    //***************************************************************************************************************
    //***************************************************************************************************************void main()
    {
    exerise  yuche;
    double Totalerror=0.0;
    int i=0,j=0;
    long Tnum=0;
    int num;
    float  *pp;
    yuche.initiate();
    num=T*P;
    pp = new float[num];
    yuche.Output(pp);//将标准输出值的首地址赋给p2
    do{
    yuche.caculatex(pp);//向前计算隐层与输出层的值
    // yuche.caculatee(pp);//计算隐层与输出层的误差值
    yuche.mat();   //求出搜索方向d
      yuche.caculatedwout();//计算wout的增量并相应的调整权值 yuche.caculatedwin();//计算win的增量并相应的调整权值
    yuche.caculatefazhiout();//计算输出层阀值的增量并相应的调整阀值
    yuche.caculatefazhimid(); //计算隐层阀值的增量并相应的调整阀值    
    //      Totalerror=yuche.judge(pp);
    Totalerror=errorsum;
                Tnum++;
    }while(Totalerror>0.000000001&&Tnum<10000);//判断总的误差和是否符合要求,否则重新计算

    predict predict1;
    predict1.suchu(yuche);
    delete[] pp;
    getch();
    cout<<"Totalerror is :";
        cout<<Totalerror<<'\n';
    cout<<"Tnum is"<<Tnum;
    }
      

  7.   

    provide "tradata.txt". I debug for you.
      

  8.   

    train.txt文件如下:
    63 117 30 57
    65 153 18 59
    72 143 28 68 
    81 178 24 67 
    95 191 39 68 
    83 141 47 85 
    78 156 23 73 
    86 152 36 59 
    91 159 45 63 
    112 167 83 83
      

  9.   

    docu.txt文件如下:1116.8 1071.7 1087.6 1070.8 1110.1 1121.5 1256.9 1368.5 1522.4 1549.1 1529.7 1490.3 1400.6 1430.1 1445.7 1384.8 1448.7 1606.9 1703.5 1690.8 1599.6 1483.2 1280.1 1102.3
    1103.8 1012.4 1034.5 991.1 1012.8 1064.8 1217.1 1337.2 1461.4 1484.9 1541.5 1463.7 1393.6 1399.2 1411.35 1364.75 1466.5 1648.2 1740.85 1672.7 1646.05 1540.6 1291.9 1142.9
    1070.9 1077.7 1032.4 995.4 1002.7 1056.4 1168.1 1303.6 1503.7 1508.7 1522.85 1478.35 1426.85 1433.95 1429.9 1411 1507.5 1602.65 1729.25 1674.85 1574.85 1489.35 1254.4 1097.25
    1058.5 1002.6 1027.3 971.4 971.4 977.4 970.4 1120.2 1434.9 1500.1 1512.15 1541.6 1338.25 1392.6 1368.95 1342.15 1488.35 1616.25 1646.4 1612.25 1496.1 1398.05 1213.3 1055.7
    1015.4 977 970.3 953.2 945.1 983.1 1083.7 1211.6 1317.5 1363.6 1421.85 1361.45 1277.3 1257.85 1280.75 1226.85 1347.75 1530.05 1551.7 1510.6 1489.9 1396.4 1213.75 1088.45
    1019.6 974.8 959 901.8 955.2 974 1086.3 1153.5 1311.7 1346.4 1368.6 1326.6 1201.65 1227.1 1230.7 1195.85 1328.75 1463.5 1572.1 1520.25 1476.7 1358.15 1189.8 1075
    965.5 951.7 917.8 912.3 919.8 1013.1 1099.7 1220.1 1369.8 1360.35 1412.8 1384.4 1322.6 1269.4 1305.25 1255.8 1355.85 1526.45 1647.1 1589.65 1548.95 1425.3 1228.4 1100.5
    1007.5 999.3 976.9 975.9 945.4 1009.3 1132.9 1251.3 1334.5 1319.2 1376.2 1330.5 1208 1234.8 1224 1226.5 1295.1 1439.3 1564.7 1536.7 1473.5 1353.1 1193.8 1174.2
    1046.2 975 974.9 948.9 947.4 963.8 1082.7 1208.6 1345 1398.5 1455.6 1439.95 1365.75 1404.5 1439.1 1472.4 1489.75 1534.15 1513.35 1567.05 1531.1 1394.7 1198.2 1043.3
    954.97 879.18 889.14 832.36 855.71 858.31 907.14 808.29 848.19 884.57 901.3 861.29 854.14 786.3 762.8 750.95 833.39 900.29 1107.88 1069.27 1070.27 1020.56 909.39 818.45
      

  10.   

    另外,能不能推荐一下深入VC调试的书或电子文档!
    非常感谢! 
    test.txt文件如下:
    989 855.2 853.1 841.7 823.7 935.1 985.1 1073.7 1150.7 1181.7 1170.5 1218.9 1144.4 1143 1121.7 1096.5 1159.2 1257.2 1383.6 1433 1401 1406.5 1383.6 1326.5 1433 823.7
      

  11.   

    1.void exerise::mat()     
    //矩阵相乘 并转化为一维
    // double tmp[Q][Q];
    // double tmp1[Q*Q];
    double (*tmp)[Q]=new double[Q][Q];
    double *tmp1=new double [Q*Q];2. exerise::exerise() while(!feof(fp))
    {
    float temp;
    fscanf(fp,"%f",&temp);
    m[i]=temp;
    i++;
                               //Add by Cline
    if(i>=(T*M))
    {
    break;
    }
                               //End add
    }
      

  12.   

    还有在exerise::mat()中的报错
    同样说“Unhandled exception in test2.exe:0xC00000FD: Stack Overflow”
      for(l=0;l<P;l++)      
       {
    double temp2;
    if(l=j) temp2=-1;
    else temp2=0;
        double temp1=1.0/2*exp(-1.0/2*xout[k][l])/(1+exp(-1.0/2*xout[k][l]))/(1+exp(-1.0/2*xout[k][l]));
    jaco[u]=temp1*temp2; (在此处报错)
    pfz[l]=temp1*temp2;
    u++;
       }
      

  13.   

    还有在exerise::mat()中的报错
    现在的错误是“Unhandled exception in test2.exe:0xC0000005: Access Violation”
    大家能不能帮我找一下原因呀
    另外,能不能推荐一下深入VC调试的书或电子文档!
    不行,大家能不能把自己在调试时遇到的问题写出来呀
    非常感谢! 
      

  14.   

    Hi,excuse me . i type english, for there is no chinese input method.jaco[u]=temp1*temp2; (在此处报错)The reason that causes this error is that the value of "u" is 
    greater than the length of "jaco". So, you should check your code.You ask how we debug. I don't find useful materials. You can debug
    by yourself.1. Set a break before the code that may cause error.(F9)
    2.When your application runs to above break,you can execute step 
      by step (F10). If you want go into a function,you can step into
      it (F11)
    3.You can open stack window to see where application is executing 
      or executes from where.
    4.You can comment some codes to know whether them play a role on
      error.
      

  15.   

    我把u改成long int还是出同样的错误出错是u=173048
    long int u 中的u可以是-2147483648 ~  2147483647
    显然u=173048<2147483647请问这可能是什么原因错误说“Unhandled exception in test2.exe:0xC0000005: Access Violation”感谢了楼主的E文真不错呀
    佩服!
      

  16.   

    Cline(营营)兄:
    你说调试要靠经验积累
    我有点不同的想法
    我觉得如果大家能把自己调试中遇到的问题写出来
    以后大家看到了
    就会首先从这个角度分析
    解决问题快一些如果一个人在黑喑中摸索中
    会耗费很多时间
    很郁闷的我觉得高手如果能把自己调试中出现的问题写出来
    把解决问题的办法写出来
    会有利于新手的提高的
      

  17.   

    int S=Q*T*P;   
    jaco=new double[S];  S is 155520, so u>=S
    I guess your code maybe like following:A.
       for(l=0;l<P;l++)      //计算偏f偏输出阈值矩阵
       {
    double temp2;
    if(l==j) temp2=-1;//Modify by Cline
    else temp2=0;
            double temp1=1.0/2*exp(-1.0/2*xout[k][l])/(1+exp(-1.0/2*xout[k][l]))
                        / (1+exp(-1.0/2*xout[k][l]));
    jaco[u]=temp1*temp2;
    pfz[l]=temp1*temp2;
    u++;
        }
    B.
     double (*tmp)[Q]=new double[Q][Q];
     double *tmp1=new double [Q*Q];
     int b1=0;
     for(i=0;i<Q;i++)
        for(j=0;j<Q;j++)
       { 
    tmp[i][j]=0;
     for(k=0;k<row;k++)
    {
                tmp[i][j]+=jc[k][i]*jc[k][j];
                //tmp1[b1]=tmp[i][j];
                //b1++;
    }
    tmp1[b1]=tmp[i][j];
    b1++;
        }An another tip:In  void exerise::Output(float *out), should guarantee value 
    of  "i" in "out[i]"  is smaller than length of out.pp = new float[num];
    yuche.Output(pp);or your application maybe not run correctly.
      

  18.   

    我上面忘了说了
    我在上面说出错的时候
    我已把S改成long int了
    long int S=Q*T*P;  也出错
    错误说“Unhandled exception in test2.exe:0xC0000005: Access Violation”
      

  19.   

    "我已把S改成long int了
    long int S=Q*T*P;  "It is not that S is greater than the max of int type.
    The reason is u in "jaco[u]" is out of lenght of array jaco[].
      

  20.   

    很有可能递归调用了,并且没有结束条件,造成堆栈溢出============================================================================
    提问题时标题要简明扼要地说明问题内容,切忌使用"急","求救"之类不能说明问题的标题
    http://alphasun.betajin.com/   遇到问题可以给我发消息,给我发信息时请附带原帖地址
    DocWizard C++程序文档自动生成工具 | Wave OpenGL | HttpProxy | AjaxParser词法分析
      

  21.   

    Unhandled exception in test2.exe:0xC00000FD: Stack Overflow
    是因为 exerise::matmat () 中 
    局部变量 占的空间太大了
    double tmp[Q][Q];
    double tmp1[Q*Q];
    double pout[N][P];  //暂时存放delta(jk)矩阵
    double pfz[P];定义成全局变量 可解决问题jaco[u]=temp1*temp2; 错误是因为 
    jaco=new double[S];  //一维动态数组jaco的声明
    中的  s 值太小了 理论估算一下 joco 的大小 考虑一下 每个 u++ 是不是 有必要。
      

  22.   

    mmm1122(蒙)兄:改成全局变量就出堆栈溢出的错误 jaco的大小不能估计
    要根据输入的数据确定
      

  23.   

    alphapaopao(炮炮) 兄:
    我没有使用递归
    结束条件清楚
    在运行到jaco[173048]时出错
      

  24.   

    Cline(营营) 兄:
       你真是个好人呀!
       你可能把我的程序看的很清楚了
       你说“"我已把S改成long int了
    long int S=Q*T*P;  "It is not that S is greater than the max of int type.
    The reason is u in "jaco[u]" is out of lenght of array jaco[].
    ”   怎样解决呀
      
       能不能给小弟指点一下
       非常感谢了
      

  25.   

    AGAIN!int S=Q*T*P;   
    jaco=new double[S];  S is 155520,jaco[173048].   173048>=155520    i.e. (u>=S)
      

  26.   

    Would you please read previous reply.............................I guess your code maybe like following:A.
       for(l=0;l<P;l++)      //计算偏f偏输出阈值矩阵
       {
    double temp2;
    if(l==j) temp2=-1;//Modify by Cline
    else temp2=0;
            double temp1=1.0/2*exp(-1.0/2*xout[k][l])/(1+exp(-1.0/2*xout[k][l]))
                        / (1+exp(-1.0/2*xout[k][l]));
    jaco[u]=temp1*temp2;
    pfz[l]=temp1*temp2;
    u++;
        }
    B.
     double (*tmp)[Q]=new double[Q][Q];
     double *tmp1=new double [Q*Q];
     int b1=0;
     for(i=0;i<Q;i++)
        for(j=0;j<Q;j++)
       { 
    tmp[i][j]=0;
     for(k=0;k<row;k++)
    {
                tmp[i][j]+=jc[k][i]*jc[k][j];
                //tmp1[b1]=tmp[i][j];
                //b1++;
    }
    tmp1[b1]=tmp[i][j];
    b1++;
        }An another tip:In  void exerise::Output(float *out), should guarantee value 
    of  "i" in "out[i]"  is smaller than length of out.pp = new float[num];
    yuche.Output(pp);or your application maybe not run correctly.
      

  27.   

    Cline(营营)兄:
      
       真是非常感谢你!
       你上面说的很对
       第一处是我大意了
       第二处我是大意了
      
       但到下面的地方就出错
        u=0;
       for(i=0;i<row;i++)
          for(j=0;j<Q;j++)
           {
         jc[i][j]=jaco[u];  (运行到i=24,j=374,u=3254时 此处报错)
      u++;
           }上面只是把这一维矩阵转化为二维矩阵
    怎么会出错呀?
    不可思议能不能指点一下?
    再次感谢!
      

  28.   

    楼上的,你看人家在这么认真的讨论问题你就不感动一下么~~~~~~~~~~ 
    hehe
      

  29.   

    On my PC, it is OK.  Are you sure (运行到i=24,j=374,u=3254时 此处报错)?For Q is 720,when i=24, u must be not smaller than 24*720=17280.
      

  30.   

    是的
    (运行到i=4,j=374,u=3254时 此处报错)Q=720 i=4 
    此时u=i*Q+j=4*720+374=3254<<172800不应该有问题呀但就在这个地方出错
    “Unhandled exception in test2.exe:0xC0000005: Access Violation.”
      

  31.   

    Are your codes same as following?   On my PC, there is no error or Access Violation. //矩阵转化(从一维到2维) 
     u=0;
     jc=new double[row][Q];
     for(i=0;i<row;i++)
        for(j=0;j<Q;j++)
      {
        jc[i][j]=jaco[u];
        u++;
       }
      

  32.   

    我现在也没有错误了
    问题在于类的构造函数中
    我把row的计算放到jc=new double[row][Q]后面了
    可能这就出了问题了非常感谢Cline(营营)兄的鼎力帮助Cline(营营)兄有没有电子邮箱
    能不能告诉我
    我的QQ:8795320
    今后有问题,好像Cline(营营)兄请教 
    我想问Cline(营营) 兄
    你怎么找出上面的这些错误的
    我也音步调试了
    但到mat()函数一出错,我就不知如何是好?
    能不能说一下
    你解决这个问题的思路
    使我也长长见识
    使我今后遇到调试错误知道如何解决麻烦Cline(营营)兄详细说一下
    在我这个程序中
    你发现一个个问题的过程
    以及解决办法希望Cline(营营) 兄能说一下我真希望向Cline(营营)兄学几着
      

  33.   

    Let's make progress together!  (I sent a message to you)
      

  34.   

    Cline兄
    消息收到了
    非常感谢我真的非常非常感谢你
    我真不知说些什么好了最后麻烦你说一下你解决问题的思路和过程吧
      

  35.   

    问题已圆满的解决非常感谢Cline(营营)兄
    我决定把100分奖给Cline(营营)兄