PAT1023. Have Fun with Numbers (20)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT1023. Have Fun with Numbers (20)相关的知识,希望对你有一定的参考价值。

#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
string a;
string b;
bool cmp(char a,char b){
	return a<b;
}
int main()
{
	cin>>a;
	b=a;
	int num;int c=0;
	for(int i=a.length()-1;i>=0;i--){
		num=(a[i]-‘0‘)*2+c;
		c=num/10;
		b[i]=num%10+‘0‘;
	}
	if(c!=0){cout<<"No"<<endl;cout<<c<<b;}
	else{
		sort(a.begin(),a.end(),cmp);
		string c=b;
		sort(b.begin(),b.end(),cmp);
		if(a.compare(b)==0){cout<<"Yes"<<endl;}
		else {cout<<"No"<<endl;}
		cout<<c;
	}
	return 0;
}

  

以上是关于PAT1023. Have Fun with Numbers (20)的主要内容,如果未能解决你的问题,请参考以下文章

PAT1023. Have Fun with Numbers (20)

PAT Advanced 1023 Have Fun with Numbers (20) [?整数运算]

PAT (Advanced Level) 1023. Have Fun with Numbers (20)

1023 Have Fun with Numbers (20分)

1023. Have Fun with Numbers

1023 Have Fun with Numbers