B-a + B Again

Source: Internet
Author: User


There must be many A + B problems in our hdoj, now A new one is coming.         Give you and hexadecimal integers, your task is to calculate the sum of them,and print it in hexadecimal too. Easy? AC it!


The input contains several test cases, please process to the end of the file.         Each case consists of the hexadecimal integers a and B in a line seperated by a blank. The length of A and B is less than 15.


For each test case,print the sum of A and B in hexadecimal on one line.

Sample Input

+a-a +1a 1a-9 -1a-12 1A-AA

Sample Output

0 2C 11-2c-90 Hex two add and output hex definition __int64 c Input Output hex with "%x" input __int64 hexadecimal "%i64x" so directly add minus but the number of computers stored in the complement result if positive It has no effect, but if it is negative, the result must be changed to a positive output printf ("-%i64x\n",-c);
#include <stdio.h>intMain () {__int64 a,b,c; Chars[ -];  while(SCANF ("%i64x%i64x", &a,&b)! =EOF) {C=a+b; if(c<0) printf ("-%i64x\n",-c); Elseprintf ("%i64x\n", c); }    return 0;}

B-a + B Again

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.