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;
}
随机推荐
- 转】Linux下安装Tomcat服务器和部署Web应用
原博文出自于: http://www.cnblogs.com/xdp-gacl/p/4097608.html 感谢! 一.上传Tomcat服务器
- gcc -D
[gcc -D] -D name Predefine name as a macro, with definition 1. 通常debug和release版的区别就在于是否有DEBUG宏,DEBUG ...
- CCS5 编译器手动设置dsp支持可变参数宏等问题
IDE:CSS5.4,compiler不支持可变参数宏.需要手动设置编译器相关选项: Language Option->Language Mode —>no strict ANSI. 1. ...
- Windows 消息机制详解
总的来说: MSG包括: 窗口句柄,指示MSG发送的目的窗口 消息标识 lPARAM.wParam 发送时间 发送时的鼠标位置 关于消息队列: Windows系统有一个系统消息队列 每个线程都有一 ...
- 手把手教你玩转SOCKET模型之重叠I/O篇(上)
“身为一个初学者,时常能体味到初学者入门的艰辛,所以总是想抽空作点什么来尽我所能的帮助那些需要帮助的人.我也希望大家能把自己的所学和他人一起分享,不要去鄙视别人索取时的贪婪,因为最应该被鄙视的是不肯付 ...
- 操作Cookie的一个陷阱服务器端获取不了maxAge或其它属性
搞了几天终于弄明白了这个问题: 在读取Cookie,然后操作时,除了getName(),getValue()外,不要妄图得到其他信息,如下方法不会得到值的:cookie.getMaxAge();=== ...
- Java读取Properties文件的六种方法
使用J2SE API读取Properties文件的六种方法 1.使用java.util.Properties类的load()方法示例: InputStream in = lnew BufferedIn ...
- 后台动态设置前台标签内容和属性(转自http://www.wzsky.net/html/Program/net/26171.html)
和以前的asp不同,在asp.net中为了彻底的代码分离,我们一般不采用<%=%>嵌入标签中来设置一些属性和内容.一般来说有2种情况:(一)设置标签的内容,比如<title>这 ...
- UI:页面传值、单例模式传值、属性传值、NSUserDefaults 数据持久化
<单页面传值> 页面传值,从前向后传值,使用属性,在后一个页面定义属性,在前一个页面,用点语法,获得值,在适当的时候传值 页面传值,从后向前面传值,使用协议和代理,在后一个页面指定协议,定 ...
- 传统的Ado.net 参数设置:params SqlParameter[] commandParameters
C#代码 ExecuteReader(string connectionString, CommandType commandType, string commandText, params Sql ...