zoukankan      html  css  js  c++  java
  • hdu Lovekey(水题)

    #include<stdio.h>
    #include<string.h>
    int a[210];
    int main()
    {
        char s1[210],s2[210];
        int l1,l2,i,j,k;
        while(scanf("%s %s",s1,s2)!=EOF)
        {
            l1=strlen(s1);
            l2=strlen(s2);
            int l11=0,l22=0;
            while(s1[l11]=='A')l11++;
            while(s2[l22]=='A')l22++;
            for(i=l1-1,j=l2-1,k=0;i>=l11&&j>=l22;i--,j--,k++)
            {
                a[k]=s1[i]+s2[j]-'A';
    
            }
            while(i>=l11)a[k++]=s1[i--];
            while(j>=l22)a[k++]=s2[j--];
    
            int jw=0;
            for(i=0;i<k;i++)
            {
                a[i]+=jw;
                if(a[i]>'Z')
                {
                    a[i]=a[i]-('Z'+1)+'A';
                    jw=1;
                }
                else jw=0;
            }
            if(jw)a[k++]=jw+'A';
            if(k==0)
            {
                printf("A
    ");
            }
            else
            {
                for(i=k-1;i>=0;i--)
                printf("%c",a[i]);
                printf("
    ");
            }
            memset(s1,0,sizeof(s1));
            memset(s2,0,sizeof(s2));
            memset(a,0,sizeof(a));
        }
        return 0;
    }

    ***

          1.数字与字母的每一步正确转换;

      2.结果为0时,输出‘A’

  • 相关阅读:
    PG
    unzip
    yum
    PG
    SQL
    Grails
    Grails
    Grails
    Chrome
    HTML
  • 原文地址:https://www.cnblogs.com/XDJjy/p/3139826.html
Copyright © 2011-2022 走看看