标题:怎么也找不出错误。。。求帮忙看一下
取消只看楼主
lyl930130
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:323
专家分:111
注 册:2013-5-13
结帖率:91.43%
已结贴  问题点数:40 回复次数:2 
怎么也找不出错误。。。求帮忙看一下
有两个错误,一个是提示第85行应输入“;”,另外一个错误很诡异,有时候出现有时候又不出现(不对代码做任何改动),提示申明与“<error-type>”acc_x4(已申明 所在行数:110)不兼容

下面是这个小函数的代码(不是主函数)

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "related_attack.h"
#define N 250
void acc(int x,int p,int n,int x1[],int x2[],int x3[],int x4[],int z[],int y[]);
void acc_x3(int x[]);
void acc_x4(int x1[],int x2[],int x3[],int x4[],int z[]);
int g(int x,int y,int z,int w);
int ensure(int x1[],int x2[],int x3[],int x4[],int z[]);

void acc_x3x4(int x1[],int x2[],int x3[],int x4[],int x[])//x是z
{
    int b[14],k[14]={0};
    int i,j,n,p=0;
    for(i=0,j=0;i<14;i++)    //找可以由x1x2直接确定的x3x4
    {
        if(x1[i]==0&&x2[i]==0&&x[i]==1)
        {
            x3[i]=1;
            x4[i]=1;
            k[j]=i;
            j++;
        }
        else if(x1[i]==0&&x2[i]==1&&x[i]==0)
        {
            x3[i]=0;
            x4[i]=1;
            k[j]=i;
            j++;
        }
        else if(x1[i]==1&&x2[i]==0&&x[i]==0)
        {
            x3[i]=1;
            x4[i]=0;
            k[j]=i;
            j++;
        }
        else if(x1[i]==0&&x2[i]==1&&x[i]==1)
        {
            x3[i]=1;
            x4[i]=1;
            k[j]=i;
            j++;
        }

    }
    n=pow(2.0,(double)(14-j));
    for(i=0;i<n;i++)
    {
        acc(i,p,n,x1,x2,x3,x4,x,k);    //p用作计数来判断x3x4是否合适
        if(p==1)
        {
            for(i=0;i<N;i++)
                if(i==0)
                    printf("x1序列:%d",x1[i]);
                else
                    printf("%d",x1[i]);
            printf("\n");
            for(i=0;i<N;i++)
                if(i==0)
                    printf("x2序列:%d",x2[i]);
                else
                    printf("%d",x2[i]);
            printf("\n");
            for(i=0;i<N;i++)
                if(i==0)
                    printf("x3序列:%d",x3[i]);
                else
                    printf("%d",x3[i]);
            printf("\n");
            for(i=0;i<N;i++)
                if(i==0)
                    printf("x4序列:%d",x4[i]);
                else
                    printf("%d",x4[i]);
            printf("\n");
            break;
        }
    }



    void acc (int x,int p,int n,int x1[],int x2[],int x3[],int x4[],int z[],int y[])
    {
        int i,j,k,m=0;
        for(i=0,j=0;i<14;i++)
        {
            if(i==y[j])
                j++;
            else
            {
                x3[i]=x%2;
                x=x/2;
            }
        }
        for(k=0;k<n;k++,m=k)
        {
            for(i=0,j=0;i<n;i++)
            {
                if(i==y[j])
                    j++;
                else
                {
                    x4[i]=m%2;
                    m=m/2;
                }
            }
            acc_x3(x3);
            acc_x4(x1,x2,x3,x4,z);
            p=ensure(x1,x2,x3,x4,z);
            if(p==250)
                break;
        }
    }

    void acc_x3(int x[])
    {
        int i;
        for(i=14;i<N;i++)
            x[i]=(x[i-2]+x[i-12]+x[i-13]+x[i-14])%2;

    } //x14  x12  x2  x  1
    void acc_x4(int x1[],int x2[],int x3[],int x4[],int z[])
    {
        int i,j;
        for(i=14;i<20;i++)
            for(j=0;j<2;j++)
                if(z[i]==g(x1[i],x2[i],x3[i],j))
                    break;
                else
                    x4[i]=i;
        for(i=20;i<N;i++)
            x3[i]=(x3[i-17]+x3[i-20])%2;
    }// x20  x3

    int g(int x,int y,int z,int w)
    {
        int i;
        i=(x+y+x*z+y*w+z*w+x*y*z+x*y*w)%2;
        return i;
    }//x1x2x1x3 x2x4x3x4x1x2x3x1x2x4

    int ensure(int x1[],int x2[],int x3[],int x4[],int z[])
    {
        int i;
        for(i=0;i<N;i++)
            if(z[i]!=g(x1[i],x2[i],x3[i],x4[i]))
                break;
        return i;
    }
搜索更多相关主题的帖子: 函数 void include 
2013-05-29 16:50
lyl930130
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:323
专家分:111
注 册:2013-5-13
得分:0 
回复 2楼 韶志
是.h文件,可以用来调用在同一个工程下的cpp文件
2013-05-29 19:16
lyl930130
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:323
专家分:111
注 册:2013-5-13
得分:0 
回复 3楼 apull
谢谢,我找了好久都没看出来
2013-05-29 19:17



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-412518-1-1.html




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

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