关键点:1、计算机中不能直接显示16进制的负数,所以需要将负数转为正数输出。2、注意使用__int64 (表示64位整数,能够表示到1800亿亿)3、在输出时要将16进制数的字母变成大写,默认是小写的。应该使用uppercase关键字。头文件<iomanip>。
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
__int64 m, n,a;
while(cin >>hex>>m>>n) {
a = m + n;
if (a<0) {
cout << "-";
cout << hex << uppercase << -a << endl;
}
else
cout << hex << uppercase << a << endl;
}
return 0;
}