当前位置: 代码迷 >> C语言 >> Counterfeit Dollar――请教一下,我的代码提示一个错误,我找不出来……
  详细解决方案

Counterfeit Dollar――请教一下,我的代码提示一个错误,我找不出来……

热度:252   发布时间:2008-05-15 12:57:20.0
Counterfeit Dollar――请教一下,我的代码提示一个错误,我找不出来……
#include <stdio.h>
#include <string.h>
int main()
{
    void add(char a[],char b[]);
    void del(char c[],char d[]);
    char left[6],right[6],status[4],light[12],heavy[12],real[12],ccoin[12];
    char rest[12],all[12],allbackup[12],lightbackup[12];
    int tt,i,j,times;
    all[]={"ABCDEFGHIJKL"};
    allbackup[]={"ABCDEFGHIJKL"};
    tt=1;
    scanf("%d",&times);
    while(tt<=times)
    {
        while(j<=3)
        {
            scanf("%s %s %s",left,right,status);
            if (strcmp(status,"even")==0)
            {
                add(left,real);add(right,real);
                del(left,all);del(right,all);
                strcpy(rest,all);strcpy(all,allbackup);
                add(rest,light);add(rest,heavy);
            }
            else if (strcmp(status,"up")==0)
            {
                add(left,heavy);add(right,light);
                del(left,all);del(right,all);
                strcpy(rest,all);strcpy(all,allbackup);
                add(rest,real);
            }
            else {
                add(left,light);add(right,heavy);
                del(left,all);del(right,all);
                strcpy(rest,all);strcpy(all,allbackup);
                add(rest,real);
            }
            j++;
        }
        strcpy(lightbackup,light);del(heavy,light);del(lightbackup,heavy);
        add(light,ccoin);add(heavy,ccoin);del(real,ccoin);
        printf("%s is the ccoin \n",ccoin);
        tt++;
    }
    return 0;
}

void add(char a[],char b[])
{
    int i,j,len;
    for(i=0;i<(strlen(a));i++)
    {
        int flag;
        for(j=0;j<(strlen(b));j++)
        {
            flag=0;
            if(a[i]==b[j])
            {
                flag=1;break;
            }
        }
        if (flag==0)
        {
            len = strlen(b);
            b[len++] = a[i];
            b[len] = '\0';
        }
    }
}

void del(char c[],char d[])
{   
    void delete(int n,char b[]);
    int i,j;
    for (i=0;i<strlen(c);i++)
    {
        for(j=0;j<strlen(d);j++)
        {
            if(c[i]==d[j]) delete(j,d);
        }
    }
}

void delete(int n,char e[])
{   
    int i;
    for(i=n;i<strlen(e);i++)
    {
        e[i]=e[i+1];
    }
}
搜索更多相关的解决方案: Counterfeit  Dollar  提示  char  

----------------解决方案--------------------------------------------------------