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. Android问题-DelphiXE5开发Andriod连接Webservice乱码问题

    问题现象:在使用DelphiXE5开发Andriod连接Webservice乱码. 问题原因:数据类型不同. 问题处理:为了不让广大朋友再烦恼,我就把解决办法写出来吧,把数据库中我们要查询的字段类型改 ...

  2. POJ 1410 Intersection(判断线段交和点在矩形内)

    Intersection Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9996   Accepted: 2632 Desc ...

  3. VISA资源名称控件

    NI-VISA能自动检测端口.通过前面板上的VISA资源名称控件或VISA查找资源函数可查看端口列表.在任何平台上,NI-VISA支持的最大串口数量为256,串口的默认数量取决于操作系统. VISA资 ...

  4. DMOZ介绍以及如何提交

    转载自 http://www.cnblogs.com/freespider/archive/2009/12/28/1633818.html Dmoz介绍及怎么提交? 1.Dmoz目录简介: Dmoz是 ...

  5. 集合类 Contains 方法 深入详解 与接口的实例

    .Net 相等性:集合类 Contains 方法 深入详解 http://www.cnblogs.com/ldp615/archive/2009/09/05/1560791.html 1.接口的概念及 ...

  6. Mathematics for Computer Graphics数学在计算机图形学中的应用 [转]

    最近严重感觉到数学知识的不足! http://bbs.gameres.com/showthread.asp?threadid=10509 [译]Mathematics for Computer Gra ...

  7. Mysql用户密码设置修改和权限分配

    我的mysql安装在c:\mysql 一.更改密码 第一种方式: 1.更改之前root没有密码的情况 c:\mysql\bin>mysqladmin -u root password " ...

  8. 使用 EasyMock 更轻松地进行测试

    from:http://www.ibm.com/developerworks/cn/java/j-easymock.html 测试驱动开发是软件开发的重要部分.如果代码不进行测试,就是不可靠的.所有代 ...

  9. javaScript 获取主机地址,项目名等

    //获取当前网址  var curWwwPath=window.document.location.href; alert(curWwwPath);  //http://localhost:8080/ ...

  10. 支付宝修改回调地址后 issign=false

    原因: verifyReturn 拼接url的时候,php自动添加了url参数,而url是本不需要的,所以导致md5对比出错. 修改  alipay_notify.class.php  77行的函数 ...