#include<iostream>
#include<stdio.h>
#include<string>
#include<math.h>
//#define MAX 2000
#define MAX 10
using namespace std;
int getChar(char x)
{
//10以内
if(x-'0'<10)
return (x-'0');
if(x-'a'>=0&&x-'a'<6)
{
return (x-'a'+10);
}
if(x-'A'>=0&&x-'A'<6)
{
return (x-'A'+10);
}
return 0;
}
int getString(char hex[])
{
int sum=0;
//首先逆序
char temp[MAX];
int i=0;
for(i=0;i<strlen(hex);i++)
{
temp[i]=hex[strlen(hex)-i-1];
}
temp[strlen(hex)]='\0';
//开始计算
for(i=0;i<strlen(hex);i++)
{
sum+=getChar(temp[i])*pow(16,i);
}
return sum;
}
int main()
{
//freopen("in.txt","r",stdin);
char a[MAX];char b[MAX];
while(scanf("%s",a)!=EOF)
{
scanf("%s",b);
cout<<getString(a)+getString(b)<<endl;
}
return 0;
}
hdoj 1720(不解释)
最新推荐文章于 2021-03-31 17:21:49 发布