| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 719 人关注过本帖
标题:error C22226 错误
只看楼主 加入收藏
lyl930130
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:323
专家分:111
注 册:2013-5-13
结帖率:91.43%
收藏
已结贴  问题点数:20 回复次数:7 
error C22226 错误
#include......
struct temp_state_data {unsigned char state[6];float state_data[2];};
......

int main()
{
}


void cal_fre()
{
    int i,j,k;
    sturct temp_state_data temp_data[200];  //就这个地方报错,error C2226 :语法错误:意外的“temp_state_data”类型
   

    看了书还是不清楚到底哪个地方出问题了。
2014-11-17 22:31
azzbcc
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:江西财经大学
等 级:贵宾
威 望:81
帖 子:3293
专家分:12919
注 册:2012-11-4
收藏
得分:0 
sturct temp_state_data temp_data[200];  //就这个地方报错,error C2226 :语法错误:意外的“temp_state_data”类型


[fly]存在即是合理[/fly]
2014-11-18 09:11
lyl930130
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:323
专家分:111
注 册:2013-5-13
收藏
得分:0 
回复 2 楼 azzbcc
这个是打的时候手误,代码里是struct
2014-11-18 20:38
lyl930130
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:323
专家分:111
注 册:2013-5-13
收藏
得分:0 
用的是VS2012
2014-11-19 16:37
azzbcc
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:江西财经大学
等 级:贵宾
威 望:81
帖 子:3293
专家分:12919
注 册:2012-11-4
收藏
得分:10 
也许是别的问题,多贴一点


[fly]存在即是合理[/fly]
2014-11-20 15:04
qjyzpsy
Rank: 2
等 级:论坛游民
帖 子:8
专家分:34
注 册:2013-4-28
收藏
得分:10 
sturct temp_state_data temp_data[200];你已经定义了结构体,这句里面不需要struct了
2014-11-21 11:22
lyl930130
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:323
专家分:111
注 册:2013-5-13
收藏
得分:0 
回复 5 楼 azzbcc
#include<stdio.h>
#include<math.h>
#define n_x_num
#define n_state_num
#define n 6
void cal_fre(unsigned char state[n_state_num][n_x_num],unsigned char *out);                           
void state_out(unsigned int init,unsigned char x[][n_x_num],unsigned char *temp);
void cal_sort(struct temp_state_data *a,int m);
void cal_choutou_i(struct temp_state_data *data,int n_choutou,unsigned int temp_num[64][2],unsigned char state[][31],unsigned

char *out);
struct temp_state_data {
                        unsigned char state[6];
                        float state_data[2];};


int main()
{
    unsigned int init=0x55abcdef;
    unsigned char out[15]={0x3a,0x39,0xcf,0xc8,0x78,0xb0,0xba,0x1e,0x6b,0x81,0xc1,0xdb,0x10,0x11,0xcf},
                  x[n_state_num][n_x_num],
                  temp[n_state_num];
    state_out(init,x,temp);
    cal_fre(x,temp);

    return 0;
}

void state_out(unsigned int init,unsigned char x[][n_x_num],unsigned char *temp)
{
    unsigned int a,b;
    int i=0,j;
    for(;i<n_state_num;i++)
    {
        for(j=0;j<n_x_num;j++)
            x[i][j]=((init<<j)&1);            
        a=(init>>2)&1 ;
        b=(init>>30)&1 ;
        a=a^b^1;
        temp[i]=a;
        init=init<<1;
        init=a&init;
    }
        
}

void cal_fre(unsigned char state[n_state_num][n_x_num],unsigned char *out)
                                                            
{
   
    unsigned int temp_num[64][2]={0},
    struct temp_state_data temp_data[470];
                                          

    int i,j,k,l,m=0,num=2;
    float temp,temp_1,temp_2,temp_3,data_x2=0,data_chahe=0;

   
    for(i=0;i<n_x_num;i++)
        for(j=i+1;j<n_x_num;j++)
        {
            for(k=0;k<n_state_num;k++)
            {                        
                unsigned char a=(state[k][i]);
                a=a<<1;
                a=a^(state[k][j]);
                temp_num[a][out[k]]++;   
            }
            
            for(l=0;l<4;l++)//4=2^2
            {
                temp_1=(float)((temp_num[l][0]-temp_num[l][1])*(temp_num[l][0]-temp_num[l][1]));
                data_x2=data_x2+temp_1;
                temp_2=(float)(temp_num[l][0]-temp_num[l][1]);
                temp_3=(float)(temp_num[l][0]+temp_num[l][1]);
                if(temp_3)
                    data_chahe=data_chahe+(float)(temp_2/temp_3);
                temp_num[l][0]=0;
                temp_num[l][1]=0;
            }
                    
            temp_data[m].state[0]=i;
            temp_data[m].state[1]=j;
            temp_data[m].state_data[0]=data_x2;
            temp_data[m].state_data[1]=data_chahe;
            m++;
        
            cal_sort(temp_data,num);
        }
    num++;

    for(i=3;i<7;i++)
    {
        cal_choutou_i(temp_data,i,temp_num,state,out);
        cal_sort(temp_data,i);
    }
}
void cal_choutou_i(struct temp_state_data *data,int n_choutou,unsigned int temp_num[64][2],unsigned char state[][31],unsigned

char *out)
{
    struct temp_state_data temp[5];
    int i,j,k,l,m,temp_1,temp_2=0;

    for(i=0;i<5;i++)
        temp[i]=data[i];
    for(temp_1=0,i=0;i<5;i++)
    {
        for(j=0;temp_1<n_x_num-n_choutou;j++,temp_1++)
        {
            if(j<temp[i].state[0])
            {                                    
                m=0;   
                for(k=n_choutou-1;k>0;k--)
                    data[temp_2+j].state[k]=data[temp_2+j].state[k-1];
                data[i].state[m]=j;
            }
            else if(j>temp[i].state[n_choutou-2])
            {
                m=n_choutou-1;        
                data[temp_2+j].state[m]=j;
            }   
            else               
                for(k=0;k<n_choutou;k++)
                    if(j>temp[i].state[k])
                    {
                        if(j<temp[i].state[k+1])
                        {
                            l=k;
                            k=n_choutou-1;
                            for(;k>l;k--)
                                data[temp_2+j].state[k]=data[temp_2+j].state[k-1];
                            data[temp_2+j].state[l]=j;
                            break;
                        }
                    }
                    else if(j==temp[i].state[k])
                    {
                        j--;
                        continue;
                    }   
        }
        temp_2=temp_2+n_x_num+1-n_choutou;
    }

   
    float data_x2=0,data_chahe=0,temp_3,temp_4;
    l=0;
    for(i=0;i<temp_2;i++)
    {
        for(j=0;j<n_state_num;j++)
        {
            unsigned int a=state[j][data[i].state[0]];
            for(k=0;k<n_choutou;k++)
            {
                a=a<<1;
                a=a^state[j][data[i].state[k]];
            }
            temp_num[a][out[k]]++;
        }
        for(l=0;l<(int)pow(2.0,n_choutou);l++)//2^n_choutou
        {
            temp_3=(float)((temp_num[l][0]-temp_num[l][1])*(temp_num[l][0]-temp_num[l][1]));
            data_x2=data_x2+temp_1;
            temp_3=(float)(temp_num[l][0]-temp_num[l][1]);
            temp_4=(float)(temp_num[l][0]+temp_num[l][1]);
            if(temp_4)
                data_chahe=data_chahe+(float)(temp_3/temp_4);
            temp_num[l][0]=0;
            temp_num[l][1]=0;
        }
        data[i].state_data[0]=data_x2;
        data[i].state_data[1]=data_chahe;

    }

}

void cal_sort(struct temp_state_data *a,int m)
{
    struct temp_state_data temp;
    int i,j,k;
    if(m==2)
        k=465;
    else
        k=5*(32-m);

    for(i=0;i<5;i++)
    {
        for(j=i+1;j<k;j++)
        {
            while(a[i].state_data[0]==a[j].state_data[0]&&a[i].state==a[j].state)
            {
                a[j]=a[k-1];
                k--;
            }
            if(a[i].state_data[0]<a[j].state_data[0])
            {
                temp=a[i];
                a[i]=a[j];
                a[j]=a[i];
            }
        }
    }
}
2014-11-24 09:05
lyl930130
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:323
专家分:111
注 册:2013-5-13
收藏
得分:0 
回复 6 楼 qjyzpsy
找到问题了。我在出错那一行的上一行定义了一个int型的变量,但是结尾用的是,而不是;所以错了
2014-11-24 09:27
快速回复:error C22226 错误
数据加载中...
 
   



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

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