PS:多出来的一位拼在前面即可
#include <iostream>
#include <string.h>
using namespace std;
int book[10];//全零说明数字出现一样
bool flag = true;
int main() {
char num[20];
cin>>num;
int numlen = strlen(num), carry = 0;
for(int i=numlen-1; i>=0; i--)
{
int temp = num[i] - '0';
book[temp]++;
temp = temp*2+carry;
carry = 0;
if(temp>=10)
{
temp = temp-10;
carry = 1;
}
num[i] = temp + '0';
book[temp]--;
}
if(carry==1)
book[carry]--;
/*判断是否一样*/
for(int i=0; i<10; i++)
{
if(book[i]!=0)
flag = false;
}
if(flag)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
if(carry==1)
cout<<carry;
cout<<num;
system("pause");
return 0;
}