文章
13
粉丝
55
获赞
2
访问
8.5k
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s1,s2;
while(cin>>s1>>s2)
{
reverse(s1.begin(),s1.end());
reverse(s2.begin(),s2.end());
// 转大写
for(int i = 0;i<s1.size();i++)
{
if(s1[i]>='a') s1[i] = toupper(s1[i]);
}
for(int i = 0;i<s2.size();i++)
{
if(s2[i]>='a') s2[i] = toupper(s2[i]);
}
if(s1.size()>s2.size())
{
for(int i = 0;i<s2.size();i++)
{
int flag = 0;
if(s1[i]>'9') flag += 10 + s1[i] - 'A';
else flag += s1[i] - '0';
if(s2[i]>'9') flag += 10 + s2[i] - 'A';
else flag += s2[i] - '0';
flag = flag%16;
if(flag<10) s1[i] = '0' + flag;
else s1[i] = 'A' + flag - 10;
}
reverse(s1.begin(),s1.end());
cout<<s1<<endl;
}else{
for(int i = 0;i<s1.size();i++)
{
int flag = 0;
if(s1[i]>'9') flag += 10 + s1[i] - 'A';
else flag += s1[i] - '0';
...
登录后发布评论
暂无评论,来抢沙发