杭电2057

来源:互联网 发布:卡密充值网站源码 编辑:程序博客网 时间:2024/06/05 09:29

用<setiosflags(ios::uppercase)<<hex来输出16进制数的大写字母

#include<iostream>

#include<iomanip>
using namespace std;
int main()
{
             long long a,b;
             while(cin>>hex>>a>>b)
             {
                             if(a+b>=0)
                                         cout<<setiosflags(ios::uppercase)<<hex<<a+b<<endl;
                             else
                                         cout<<'-'<<setiosflags(ios::uppercase)<<hex<<-(a+b)<<endl;
              }
}
原创粉丝点击