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;
}
随机推荐
- 【转】Hive学习路线图
原文博客出自于:http://blog.fens.me/hadoop-hive-roadmap/ 感谢! Hive学习路线图 Hadoop家族系列文章,主要介绍Hadoop家族产品,常用的项目包括Ha ...
- Spark RDD概念学习系列之RDD的操作(七)
RDD的操作 RDD支持两种操作:转换和动作. 1)转换,即从现有的数据集创建一个新的数据集. 2)动作,即在数据集上进行计算后,返回一个值给Driver程序. 例如,map就是一种转换,它将数据集每 ...
- jBox使用方法
1.引入jquery文件 2.引入css和jBox文件 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml& ...
- Styling FX Buttons with CSS
http://fxexperience.com/2011/12/styling-fx-buttons-with-css/ ——————————————————————————————————————— ...
- C# JackLib系列之Form窗体的ShowWithoutActivation属性及其作用
代码改变世界! 如果要显示顶级窗口,但又不希望由于将输入焦点从当前窗口移开而中断用户的工作,请使用此属性.它可以是一个信息性弹出窗口或浮动窗口,如“画图”应用程序中的“工具”调色板. 由于此属性为只读 ...
- Linux内核完全注释之编程语言和环境(二)
c程序的编译和链接 使用gcc汇编器编译c语言程序时通常会经历四个阶段,即预处理阶段.编译阶段.汇编阶段.链接阶段,如下图. 例如: gcc -o hello hello.c 生成可执行文件hello ...
- Objective-C 学习记录--toches、Motion/Size/Rect/Point/CGFloat/protocol
- (void)touchesBegan touchesEnd touchesCancelled touchesMoved //代表的是手指在屏幕上的动作,开始 结束 取消 移动 //还有就是代表摇动 ...
- IDA Script: Remove empty auto labels
http://simeonpilgrim.com/blog/2010/03/25/ida-script-remove-empty-auto-labels/ #include <idc.idc&g ...
- TCP连接(Time_Wait、Close_Wait)说明
修改Time_Wait和CLOSE_WAIT时间 修改Time_Wait参数的方法 (在服务端修改)Windows下在HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlS ...
- linux 源码编译(转)
源代码的用处无非是以下两点;1、软件根据用户的需要加以定制;2、二次开发;注:要根据软件的许可证书约定为准,开发者许可二次开发才行;1、源码包的打包格式;源代码一般以file.tar.gz file. ...