(杭电2053)A + B Again(转换说明符)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 39021 Accepted Submission(s): 15794
Problem Description
There must be many A + B problems in our HDOJ , now a new one is coming.
Give you two hexadecimal integers , your task is to calculate the sum of them,and print it in hexadecimal too.
Easy ? AC it !
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
过年玩的有点嗨......emmmm....... 一开始打算用字符串储存之后一个个分析结果老是WA。。。。。。逛了一下讨论区看到了dalao们写的ac码 如下
#include <stdio.h>
int main(void)
{
long long i,a,b,sum;
while(scanf("%I64X %I64X",&a,&b) != EOF)
{
sum = a+b;
if(sum >= 0)
{
printf("%I64X\n",sum);
}
else
{
sum = -sum;
printf("-%I64X\n",sum);
}
}
}
发现了%x这个符号,在论坛上找出一串相关符号
(以下转自网站)
转换说明符
%a(%A) 浮点数、十六进制数字和p-(P-)记数法(C99)
%c 字符
%d 有符号十进制整数
%f 浮点数(包括float和doulbe)
%e(%E) 浮点数指数输出[e-(E-)记数法]
%g(%G) 浮点数不显无意义的零"0"
%i 有符号十进制整数(与%d相同)
%u 无符号十进制整数
%o 八进制整数 e.g. 0123
%x(%X) 十六进制整数0f(0F) e.g. 0x1234
%p 指针
%s 字符串
%% "%"
2`标志
左对齐:"-" e.g. "%-20s"
右对齐:"+" e.g. "%+20s"
空格:若符号为正,则显示空格,负则显示"-" e.g. "% 6.2f"
#:对c,s,d,u类无影响;对o类,在输出时加前缀o;对x类,在输出时加前缀0x;
对e,g,f 类当结果有小数时才给出小数点。
3.格式字符串(格式)
〔标志〕〔输出最少宽度〕〔.精度〕〔长度〕类型
"%-md" :左对齐,若m比实际少时,按实际输出。
"%m.ns":输出m位,取字符串(左起)n位,左补空格,当n>m or m省略时m=n
e.g. "%7.2s" 输入CHINA
输出" CH"
"%m.nf":输出浮点数,m为宽度,n为小数点右边数位
e.g. "%3.1f" 输入3852.99
输出3853.0
(杭电2053)A + B Again(转换说明符)的更多相关文章
- 杭电2053 WA
#include<stdio.h> int main() { ]; while(scanf("%d",&n)!=EOF) { ;i<=;i++) { a[ ...
- 进制转换,杭电0j-2031
进制转换,杭电0j-2031原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=2031 [Problem Description] 输入一个十进制数N,将它 ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- 杭电ACM(1002) -- A + B Problem II 大数相加 -提交通过
杭电ACM(1002)大数相加 A + B Problem II Problem DescriptionI have a very simple problem for you. Given two ...
- 杭电dp题集,附链接还有解题报告!!!!!
Robberies 点击打开链接 背包;第一次做的时候把概率当做背包(放大100000倍化为整数):在此范围内最多能抢多少钱 最脑残的是把总的概率以为是抢N家银行的概率之和- 把状态转移方程写成了f ...
- 杭电ACM题单
杭电acm题目分类版本1 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最 ...
- 2018 Multi-University Training Contest 1 杭电多校第一场
抱着可能杭电的多校1比牛客的多校1更恐怖的想法 看到三道签到题 幸福的都快哭出来了好吗 1001 Maximum Multiple(hdoj 6298) 链接:http://acm.hdu.edu. ...
- 杭电acm习题分类
专注于C语言编程 C Programming Practice Problems (Programming Challenges) 杭电ACM题目分类 基础题:1000.1001.1004.1005. ...
- acm入门 杭电1001题 有关溢出的考虑
最近在尝试做acm试题,刚刚是1001题就把我困住了,这是题目: Problem Description In this problem, your task is to calculate SUM( ...
随机推荐
- npm install warning: no description; no repository field
npm install 报错:warning no description; no repository field 开始以为必须npm init,npm init在git bash(win7)里,还 ...
- Hadoop学习---Eclipse中hadoop环境的搭建
在eclipse中建立hadoop环境的支持 1.需要下载安装eclipse 2.需要hadoop-eclipse-plugin-2.6.0.jar插件,插件的终极解决方案是https://githu ...
- Linux账号管理和ACL
by zjmyster version :1.2 Linux账号管理和ACL权限设置: 主要相关配置文件:/etc/passwd /etc/shadow /etc/group /etc/gshadow ...
- W3School学习网站
http://www.w3school.com.cn/tags/att_form_autocomplete.asp
- Apache PredictionIO在Docker上的搭建及使用
1.Apache PredictionIO介绍 Apache PredictionIO 是一个孵化中的机器学习服务器,它可以为为开发人员和数据科学家创建任何机器学习任务的预测引擎.官方原文: Apac ...
- UVA11987 【Almost Union-Find】
这是一道神奇的题目,我调了大概一天多吧 首先hack一下翻译,操作3并没有要求查询后从其所在集合里删除该元素 于是我们来看一下这三个操作 第一个合并属于并查集的常规操作 第三个操作加权并查集也是可以解 ...
- Codeforces Round #533 (Div. 2) B. Zuhair and Strings 【模拟】
传送门:http://codeforces.com/contest/1105/problem/B B. Zuhair and Strings time limit per test 1 second ...
- UDP and TCP
UDP unreliable, just add de-multiplexing and error checking on data than IP. Best effort datagram(数据 ...
- input输入框中list属性不能没有效果
网页代码入下,就是出不来效果. 人物:zslsww 解决办法: 将option中的value属性去掉: 张山李四王五爪留 显示效果,问题得到解决.
- Oracle树形结构数据-相关知识总结
Oracle树形结构数据--基本知识 1.数据组成 2.基本查询 2.1.查询某节点及该节点下的所有子孙节点 SELECT * FROM QIANCODE.TREE_TABLE_BASI ...