杭电OJ | 2057 A+B Again dev c++下的基本类型、位数、取值范围

笔记:

1. Dev c++下基本类型所占位数和取值范围(Dev-C++)

参考:https://blog.csdn.net/u010388659/article/details/81475580

符号               长度    基本型     位数       取值范围       输入符举例      输出符举例

--                    --           char         8         -2^7 ~ 2^7-1        %c          %c、%d、%u

signed            --           char         8         -2^7 ~ 2^7-1        %c          %c、%d、%u

unsigned        --           char         8         0 ~ 2^8-1             %c          %c、%d、%u

[signed]        short        [int]        16          -2^15 ~ 2^15-1              %hd

unsigned      short        [int]        16          0 ~ 2^16-1               %hu、%ho、%hx

[signed]          --             int         32         -2^31 ~ 2^31-1              %d

unsigned        --            [int]        32         0 ~ 2^32-1                %u、%o、%x

[signed]         long         [int]        32        -2^31 ~ 2^31-1              %ld

unsigned       long         [int]        32         0 ~ 2^32-1                  %lu、%lo、%lx

[signed]      long long    [int]        64         -2^63 ~ 2^63-1             %I64d

unsigned     long long   [int]        64         0 ~ 2^64-1                 %I64u、%I64o、%I64x

--                   --             float        32         +/- 3.40282e+038         %f、%e、%g

--                   --            double     64         +/- 1.79769e+308      %lf、%le、%lg   %f、%e、%g

--                  long         double     96        +/- 1.79769e+308        %Lf、%Le、%Lg

 

题目是15位的十六进制,要用64位的%I64,由于输出要大写,所以要用大写的X,也就是%I64X。由于是unsigned,所以要注意输出的格式。

参考:http://acm.hdu.edu.cn/faq.php

Signed 64-bit integer. Value range: -9223372036854775808 .. 9223372036854775807.

LanguageGCC/G++PascalC/C++
Type name__int64
or
long long
int64__int64
Inputscanf("%I64d", &x);
or
cin >> x;
read(x);scanf("%I64d", &x);
Outputprintf("%I64d", x);cout << x; write(x);printf("%I64d", x);

Unsigned 64-bit integer. Value range: 0 .. 18446744073709551615.

LanguageGCC/G++PascalC/C++
Type nameunsigned __int64
or
unsigned long long
qwordunsigned __int64
Inputscanf("%I64u", &x);
or
cin >> x;
read(x);scanf("%I64u", &x);
Outputprintf("%I64u", x);
or cout << x;
write(x);printf("%I64u", x);

2057 A + B Again

Input

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

Output

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

Sample Input

+A -A

+1A 12

1A -9

-1A -12

1A -AA

Sample Output

0

2C

11

-2C

-90

#include <stdio.h>
int main()
{
    __int64 a,b;     //用long long也过了,但是更普遍的是__int64
    while(scanf("%I64x%I64x",&a,&b)!=EOF)
    {
        if(a+b<0)
            printf("-%I64X\n",-(a+b));
        else
            printf("%I64X\n",a+b);
    }
    return 0;
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值