| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 856 人关注过本帖
标题:我编了一个程序 感觉没有问题 但是编译的时候有一堆error 自己实在不知道怎 ...
取消只看楼主 加入收藏
zhht87
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2013-8-7
结帖率:57.14%
收藏
已结贴  问题点数:10 回复次数:1 
我编了一个程序 感觉没有问题 但是编译的时候有一堆error 自己实在不知道怎么改 求大神帮忙
我编了一个程序 感觉没有问题 但是编译的时候有一堆error  自己实在不知道怎么改 求大神帮忙

报告的错误如下
Compiling...
OR.c
C:\Documents and Settings\Administrator\桌面\C2\OR.c(45) : error C2143: syntax error : missing ';' before '<class-head>'
C:\Documents and Settings\Administrator\桌面\C2\OR.c(48) : error C2079: 'con' uses undefined struct 'con'
C:\Documents and Settings\Administrator\桌面\C2\OR.c(48) : error C2078: too many initializers
C:\Documents and Settings\Administrator\桌面\C2\OR.c(77) : warning C4305: 'initializing' : truncation from 'const double ' to 'float '
C:\Documents and Settings\Administrator\桌面\C2\OR.c(86) : error C2059: syntax error : 'for'
C:\Documents and Settings\Administrator\桌面\C2\OR.c(86) : error C2143: syntax error : missing '{' before '<='
C:\Documents and Settings\Administrator\桌面\C2\OR.c(86) : error C2059: syntax error : '<='
C:\Documents and Settings\Administrator\桌面\C2\OR.c(86) : warning C4142: benign redefinition of type
C:\Documents and Settings\Administrator\桌面\C2\OR.c(86) : error C2059: syntax error : ')'
C:\Documents and Settings\Administrator\桌面\C2\OR.c(87) : error C2099: initializer is not a constant
C:\Documents and Settings\Administrator\桌面\C2\OR.c(87) : error C2143: syntax error : missing ';' before 'for'
C:\Documents and Settings\Administrator\桌面\C2\OR.c(87) : error C2143: syntax error : missing '{' before '<='
C:\Documents and Settings\Administrator\桌面\C2\OR.c(87) : error C2059: syntax error : '<='
C:\Documents and Settings\Administrator\桌面\C2\OR.c(87) : fatal error C1903: unable to recover from previous error(s); stopping compilation
执行 cl.exe 时出错.

OR.obj - 1 error(s), 0 warning(s)


程序如下:



#include <stdio.h>
#include <math.h>
#include <stdlib.h>


#define Pi 3.14159    //角度弧度化所用参数
#define Imax 200     //一共有多少个点

//能够容忍的取向差的最大值需要在fccorientation函数中设定
//需要分别输入导入和导出的文件的位置


void matproduct(float a2[3][3],float b2[3][3],float c2[3][3]);
float misorientation(float con1[3][3],float fcc1[3][3],float con2[3][3],float bcc1[3][3],float or2[3][3]);
void transpose(float a3[3][3]);




int main()
{
    int i;//定义主程序中使用的循环变量
    float part[Imax][3];

                        
    FILE *in;
    if((in=fopen("C:\\c program\\hudu1.txt","r"))==NULL)  //需要输入导入文件的存放地址
    {printf("cannot open file\n");
     exit(0);
    }
    else
    {for(i=0;i<Imax;i++)  //Imax 为一共有多少个点

    fscanf(in,"%f %f %f",part[i][0],part[i][1],part[i][2]);
    }

    fclose(in);//将txt文件输入input数组的语句


    for(i=0;i<Imax;i++)
    printf("%f %f %f\n",part[i][0],part[i][1],part[i][2]);


 struct convert
 {float C[3][3];};
  struct convert con[24]=
    {
        {1,0,0,0,1,0,0,0,1},
        {0,0,-1,0,-1,0,-1,0,0},
        {0,0,-1,0,1,0,1,0,0},
        {-1,0,0,0,1,0,0,0,-1},
        {0,0,1,0,1,0,-1,0,0},
        {1,0,0,0,0,-1,0,1,0},
        {1,0,0,0,-1,0,0,0,-1},
        {1,0,0,0,0,1,0,-1,0},
        {0,-1,0,1,0,0,0,0,1},
        {-1,0,0,0,-1,0,0,0,1},
        {0,1,0,-1,0,0,0,0,1},
        {0,0,1,1,0,0,0,1,0},
        {0,1,0,0,0,1,1,0,0},
        {0,0,-1,-1,0,0,0,1,0},
        {0,-1,0,0,0,1,-1,0,0},
        {0,1,0,0,0,-1,-1,0,0},
        {0,0,-1,1,0,0,0,-1,0},
        {0,0,1,-1,0,0,0,-1,0},
        {0,-1,0,0,0,-1,1,0,0},
        {0,1,0,1,0,0,0,0,-1},
        {-1,0,0,0,0,1,0,1,0},
        {0,0,1,0,-1,0,1,0,0},
        {0,-1,0,-1,0,0,0,0,-1},
        {-1,0,0,0,0,-1,0,-1,0},

    };

 float fc[3],or1[3];
 float a1,b1,c1,a,b,c,o,p,q,x,y,z,x1,y2,z1,Omin,Oaver,Osum,O;
 float Oavermin=Pi;                            //abc组合当中的取向差的最小值   
 float Ocritical=1;                           //直接输入数据不要输入公式 计算得到的取向差需要符合的外部条件,可以通过计算结果进行调整
 float Mfcc[3][3],Mbcc[3][3],or[3][3];
 int num,m,n;


 


 for(a=0.0;a<=90;a=a+0.1)  //需要检查角度的范围
 for (b=0.0;b<=90;b=b+0.1)
 for (c=0.0;c<=90;c=c+0.1)
 for (x=0.0;x<=90;x=x+0.1)  //需要检查角度的范围
 for (y=0.0;y<=90;y=y+0.1)
 for (z=0.0;z<=90;z=z+0.1)
            {
             a1=a/180.0*Pi;
             b1=b/180.0*Pi;
             c1=c/180.0*Pi;
             Mfcc[0][0]=(cos(a1)*cos(c1)-sin(a1)*sin(c1)*cos(b1));
             Mfcc[0][1]=(sin(a1)*cos(c1)+cos(a1)*sin(c1)*cos(b1));
             Mfcc[0][2]=sin(c1)*sin(b1);
             Mfcc[1][0]=(-cos(a1)*sin(c1)-sin(a1)*cos(c1)*cos(b1));
             Mfcc[1][1]=(-sin(a1)*sin(c1)+cos(a1)*cos(c1)*cos(b1));
             Mfcc[1][2]=cos(c1)*sin(b1);
             Mfcc[2][0]=sin(a1)*sin(b1);
             Mfcc[2][1]=-cos(a1)*sin(b1);
             Mfcc[2][2]=cos(b1);

             x1=x/180.0*Pi;
             y2=y/180.0*Pi;
             z1=z/180.0*Pi;
             or[0][0]=(cos(x1)*cos(z1)-sin(x1)*sin(z1)*cos(y2));
             or[0][1]=(sin(x1)*cos(z1)+cos(x1)*sin(z1)*cos(y2));
             or[0][2]=sin(z1)*sin(y2);
             or[1][0]=(-cos(x1)*sin(z1)-sin(x1)*cos(z1)*cos(y2));
             or[1][1]=(-sin(x1)*sin(z1)+cos(x1)*cos(z1)*cos(y2));
             or[1][2]=cos(z1)*sin(y2);
             or[2][0]=sin(x1)*sin(y2);
             or[2][1]=-cos(x1)*sin(y2);
             or[2][2]=cos(y2);


             Osum=0;
             num=0;
             for (i=0;i<Imax;i++)
             {
                 
              o=par[i][0];
              p=par[i][1];
              q=par[i][2];
              if ((o==0)&&(p==0)&&(q==0))
              {
               Omin=0;
              }                     //对应if条件语句
              else
              {
               Mbcc[0][0]=cos(o)*cos(q)-sin(o)*sin(q)*cos(p);      //由于初始化在程序的外边所以只能单独赋值
               Mbcc[0][1]=sin(o)*cos(q)+cos(o)*sin(q)*cos(p);
               Mbcc[0][2]=sin(q)*sin(p);
               Mbcc[1][0]=-cos(o)*sin(q)-sin(o)*cos(q)*cos(p);
               Mbcc[1][1]=-sin(o)*sin(q)+cos(o)*cos(q)*cos(p);
               Mbcc[1][2]=cos(q)*sin(p);
               Mbcc[2][0]=sin(o)*sin(p);
               Mbcc[2][1]=-cos(o)*sin(p);
               Mbcc[2][2]=cos(p);
              



               Omin=Pi;
               for (m=0;m<24;m++)
                for (n=0;n<24;n++)
                { O=misorientation(con[m].C,Mfcc,con[n].C,Mbcc,or);
               
                   if (O<Omin)
                       Omin=O;
                }                   //对应for条件语句
              }                     //对应else 条件语句


              Osum=Osum+Omin;
              num++;
             }                      //对应i层次的for 循环结束
             Oaver=Osum/num;

             if ((Oavermin>=Oaver)&&(Oaver<=Ocritical))   //在a,b,c的变化范围内寻找取向差最小的abc组合,同时最小的取向差还需要满足程序开始设定的标准Ocritical
             {fc[0]=a;
              fc[1]=b;
              fc[2]=c;
              or1[0]=x;
              or1[1]=y;
              or1[2]=z;
             }

            }//对应最上边角度变化的for语句

   


printf("Mfcc= f% %f %f\n",fc[0],fc[1],fc[2]);
printf("or  = f% %f %f\n",or1[0],or1[1],or1[2]);

return(0);
}








 






float misorientation(float con1[3][3],float fcc1[3][3],float con2[3][3],float bcc1[3][3],float or2[3][3])
{int i;
 float O1;
 float a1[3][3],b1[3][3],c1[3][3],d1[3][3];



 matproduct(or,con1,a1);


 matproduct(a1,fcc1,b1);
 
 matproduct(con2,bcc1,c1);


 transpose(c1);



 matproduct(b1,c1,d1);
 //for(i=0;i<3;i++)
     //printf("%f %f %f\n",d1[i][0],d1[i][1],d1[i][2]);
if((d1[0][0]+d1[1][1]+d1[2][2]-1)/2>=1)
O1=0;
else if((d1[0][0]+d1[1][1]+d1[2][2]-1)/2<=-1)
O1=3.14159;
else
 O1=acos((d1[0][0]+d1[1][1]+d1[2][2]-1)/2);

 //printf("%f",O1);

 return(O1);
}


void matproduct(float a2[3][3],float b2[3][3],float c2[3][3])      //对矩阵进行乘法运算,结果存储到c矩阵中
{int i1,j1;
 for (i1=0;i1<3;i1++)
     for (j1=0;j1<3;j1++)
         {c2[i1][j1]=a2[i1][0]*b2[0][j1]+a2[i1][1]*b2[1][j1]+a2[i1][2]*b2[2][j1];}
}


void transpose(float a3[3][3])//对矩阵进行转置运算
{float c3;
 c3=a3[0][1];
 a3[0][1]=a3[1][0];
 a3[1][0]=c3;
 c3=a3[0][2];
 a3[0][2]=a3[2][0];
 a3[2][0]=c3;
 c3=a3[1][2];
 a3[1][2]=a3[2][1];
 a3[2][1]=c3;
}
搜索更多相关主题的帖子: undefined Documents before 
2013-08-12 23:23
zhht87
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2013-8-7
收藏
得分:0 
问题已经解决了 是定义参数位置引起的,已经修改通过了 谢谢!
2013-08-12 23:48
快速回复:我编了一个程序 感觉没有问题 但是编译的时候有一堆error 自己实在不 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.043584 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved