zoukankan      html  css  js  c++  java
  • uva 213

    #include<stdio.h>
    #include<math.h>
    #include<string.h>
    char s[250];
    char a[10][250];
    int a1[4];
    int a2[250];
    char ch;
    
    int init(int len)
    {
        int tt=0;
        for(int i=1;i<=7;i++)
        {
            for(int j=0;j<(int)pow(2,i)-1;j++)
            {
                a[i][j]=s[tt++];
                if(tt>=len)
                    break;
            }
            if(tt>=len)
                break;
        }
    }
    
    int tran(int *aa,int len)
    {
        int temp=0;
        for(int i=len-1,j=0; i>=0; i--,j++)
        {
            temp+=(int)aa[i]*pow(2,j);
        }
        return temp;
    }
    
    int main()
    {
        while(gets(s)!=NULL)
        {
            memset(a,0,sizeof(a));
            int len=strlen(s);
            init(len);
    
            while(1)
            {
                int t2=0;
                while(t2<3)
                {
                    scanf("%c",&ch);
                    if(ch=='1'||ch=='0')
                    {
                        a1[t2]=ch-'0';
                        t2++;
                    }
                }
                int lenth=tran(a1,3);
                if(lenth==0)
                {
                    scanf("%c",&ch);
                    printf("
    ");
                    break;
                }
                while(1)
                {
                    int t3=0;
                    while(t3<lenth)
                    {
                        scanf("%c",&ch);
                        if(ch=='1'||ch=='0')
                        {
                            a2[t3]=ch-'0';
                            t3++;
                        }
                    }
                    int ans=tran(a2,lenth);
                    if(ans!=(int)pow(2,lenth)-1)
                        printf("%c",a[lenth][ans]);
                    else
                        break;
                }
            }
        }
        return 0;
    }
    

  • 相关阅读:
    mysql
    mysql
    mysql
    mysql
    mysql
    mysql
    mysql
    mysql
    mysql
    为你的react项目添加路由
  • 原文地址:https://www.cnblogs.com/mfmdaoyou/p/6685037.html
Copyright © 2011-2022 走看看