Problem Description
Many classmates said to me that A+B is must needs.
If you can’t AC this problem, you would invite me for night meal.
^_^
 
Input
Input may contain multiple test cases. Each case
contains A and B in one line.
A, B are hexadecimal number.
Input
terminates by EOF.
 
Output
Output A+B in decimal number in one line.
 
Sample Input
1 9
A B
a b
 
Sample Output
10
21
21
 
 #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;
}

随机推荐

  1. Javascript事件处理进阶

    这篇文章是我在看乌龟书<编写可维护的Javascript>发现的一篇写的非常好的章节,在这里我并不会教大家什么是绑定事件等比较基础的事.有兴趣了解DOM事件的同学们,可以去w3cschoo ...

  2. 用keyword实现Editor.GetSelection的退出功能

    有时候我们在使用 GetSelection 功能让用户选择实体时,可能会给用户提供一些 keyword 选项,要接收用户选择的 keyword 选项,需要用到 PromptSelectionOptio ...

  3. linux极点五笔无法输入词组_ibus设置

    菜鸟学linux——用的是ubuntu 不知道是不是按个哪些快捷键,极点五笔突然无法输入词组.那个抓狂啊 没关系,设置一下就ok 第一步:右上角输入法,右键——>首选项——>常规——> ...

  4. MSSQL手札三 MSSQL存储过程

    --存储过程完成一段sql代码的封装 create proc trim --参数列表,多个间用逗号分隔 ) as --自定义代码段 ) set @str1=LTRIM(RTRIM(@str)) pri ...

  5. JDBC 常用驱动类及url格式

    1. oracle <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</ ...

  6. 引用 1.9.1.min.js dom对象 没有live 绑定事件方法, 引用 1.7.js 就有live 绑定事件方法

    问题:相同环境,引用 1.9.1.min.js $('div[data-role="page"]').live('pagehide', function (event, ui) { ...

  7. 浏览器URL访问网页具体发生了什么

    [详细讲解:http://www.cnblogs.com/wenanry/archive/2010/02/25/1673368.html]   ——浏览器输入URL ——DNS解析过程 解析域名,找到 ...

  8. thinkphp 3+ 观后详解 (5)

    static public function dispatch() { $varPath = C('VAR_PATHINFO'); $varAddon = C('VAR_ADDON'); $varMo ...

  9. pat 1055 区间前k个

    http://pat.zju.edu.cn/contests/pat-a-practise/1055 第二组数据比较大,如果单纯排序直接检索会超时,因为每次都是对所有数据进行遍历. N/200=500 ...

  10. wpa_supplicant 移植及 linux 命令行模式配置无线上网

    本文涉及内容为linux 命令行模式配置无线上网 及 wpa_supplicant 移植到开发板的过程,仅供参考. 1.源码下载 wpa_supplicant 源码下载地址 :http://hosta ...