A+B Coming
If you can’t AC this problem, you would invite me for night meal.
^_^
contains A and B in one line.
A, B are hexadecimal number.
Input
terminates by EOF.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h> int decimal(char s[]); int main(){
char s1[];
char s2[];
int number1;
int number2; while(scanf("%s%s",s1,s2)!=EOF){
number1=decimal(s1);
number2=decimal(s2); printf("%d\n",number1+number2); } return ;
} int decimal(char s[]){
int result=;
int i;
int length;
int temp; length=strlen(s); for(i=length-;i>=;i--){
if(isdigit(s[i]))
temp=s[i]-''; else if(s[i]=='A' || s[i]=='a')
temp=; else if(s[i]=='B' || s[i]=='b')
temp=; else if(s[i]=='C' || s[i]=='c')
temp=; else if(s[i]=='D' || s[i]=='d')
temp=; else if(s[i]=='E' || s[i]=='e')
temp=; else if(s[i]=='F' || s[i]=='f')
temp=; result+=temp*pow(,length--i);
} return result;
}
随机推荐
- 【转】Eclipse去除js(JavaScript)验证错误
这篇文章主要是对Eclipse去除js(JavaScript)验证错误进行了介绍.在Eclipse中,js文件常常会报错.可以通过如下几个步骤解决 第一步:去除eclipse的JS验证:将window ...
- 再看Core Data中PSC陷入死锁的问题
在<Core Data Programming Guide>文档的Concurrency with Core Data这一章节中提到了“Use Thread Confinement to ...
- LOTUS 迁移到Exchange 2010 POC 之在Exchange 2007 安装Lotus Admin!
双击Setup安装:
- Bluetooth in Android 4.2 and 4.3(一):综述
从Android 4.2开始,Bluetooth stack发生了重大改变:从Bluez换成了由Google和Broadcom联合开发的Bluedroid(当然,核心的部分还是Broadcom的,Go ...
- 6 种CSS设置居中的方法
原文 Demos of each of the methods below by clicking here. Horizontal centering with css is rather easy ...
- Labeled ContentControl & LabeledControl【项目】
LabeledTextBoxControl: C#定义 using System; using System.Collections.Generic; using System.Linq; using ...
- 【汉字乱码】IE下GET形式传递汉字。
js:encodeURI(); php:urlencode(); 举例: 本来打算这样使用 <a href="list.php?plate=辖区动态" charset=&qu ...
- chrome 41 空格
chrome 41对半角空格的解析 当做一个汉字宽度来处理了. 导致很多网站出现异常. 目前能想到的方法是删掉用来规范格式的空格. 老版chrome chrome41 和讯网也有这种问题 有更好的处理 ...
- HTML第四天学习笔记
今天老师教了下无序列表和有序列表,虽然并没有,同时做了个随堂练习: <html> <head> <title>随堂练习00</title> <me ...
- Java异常处理中finally中的return会覆盖catch语句中的return语句
Java异常处理中finally中的return会覆盖catch语句中的return语句和throw语句,所以Java不建议在finally中使用return语句 此外 finally中的throw语 ...