HDU-2097

原题点击打开链接

#include
#include
#include
int main(void){
int i,n,a10,a16,a12,sum,len16,len12;
char num[5],num16[5],num12[5];
while(scanf("%s",num)!=EOF){
    if(num[0]=='0')break;
    sum=0;a10=0;
    for(i=0;i<4;i++){a10=a10*10+(num[i]-'0');sum=sum+num[i]-'0';}
    itoa(a10,num16,16);
    itoa(a10,num12,12);
    len16=strlen(num16);
    len12=strlen(num12);
    a16=0;a12=0;
    for(i=0;i='0'&&num16[i]<='9')a16=a16+(num16[i]-'0');
            else if(num16[i]>='A'&&num16[i]<='F')a16=a16+(num16[i]-'A'+10);
            else if(num16[i]>='a'&&num16[i]<='f')a16=a16+(num16[i]-'a'+10);
            }
    for(i=0;i='0'&&num12[i]<='9')a12=a12+(num12[i]-'0');
            else if(num12[i]>='A'&&num12[i]<='B')a12=a12+(num12[i]-'A'+10);
            else if(num12[i]>='a'&&num12[i]<='b')a12=a12+(num12[i]-'a'+10);
            }
            if(a16==sum&&a12==sum)printf("%s is a Sky Number.\n",num);
            else printf("%s is not a Sky Number.\n",num);
}
return 0;
}


你可能感兴趣的:(水题,杂题,HDU)