00-自测4. Have Fun with Numbers (20)
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
int a[20],b[20],i,len1,len2,flag,j,t,d;
char s[25],s2[25];
while(~scanf("%s",s))
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(s2,0,sizeof(s2));
len1=strlen(s);
for(i=0; i<len1; i++)
a[s[i]-48]++;
d=0;
j=0;
for(i=len1-1;i>=0;i--)
{
t=s[i]-48;
t=t*2+d;
d=t/10;
t%=10;
s2[j++]=t+48;
}
len2=strlen(s2);
if(d>0) {s2[j++]=d+48;len2++;}
for(i=0; i<len2; i++)
b[s2[i]-48]++;
flag=1;
for(i=0; i<=9; i++)
if(a[i]!=b[i])
{
flag=0;
break;
}
if(flag) printf("Yes\n");
else printf("No\n");
for(i=len2-1; i>=0; i--)
printf("%c",s2[i]);
printf("\n");
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/