笔记:
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.
Language | GCC/G++ | Pascal | C/C++ |
Type name | __int64 or long long | int64 | __int64 |
Input | scanf("%I64d", &x); or cin >> x; | read(x); | scanf("%I64d", &x); |
Output | printf("%I64d", x); | cout << x; write(x); | printf("%I64d", x); |
Unsigned 64-bit integer. Value range: 0 .. 18446744073709551615.
Language | GCC/G++ | Pascal | C/C++ |
Type name | unsigned __int64 or unsigned long long | qword | unsigned __int64 |
Input | scanf("%I64u", &x); or cin >> x; | read(x); | scanf("%I64u", &x); |
Output | printf("%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;
}