A+B II
#include<stdio.h>
#include<string.h>
int main()
{
char a[],b[],c[];
int T,T1;
scanf("%d",&T);
T1=T;
getchar();
while(T--)
{
int alen,blen,clen,i,j,k=,p=;
memset(a,,sizeof(a));
memset(b,,sizeof(b));
memset(c,,sizeof(c));
scanf("%s%s",a,b);
alen=strlen(a),blen=strlen(b);
for(i=alen-,j=blen-;;)
{
c[k]=(a[i]+b[j]-''-''+p)%+'';
p=(a[i]+b[j]-''-''+p)/;
if(i==&&j==)
{
if(p>)
{
c[++k]='';
break;
}
break;
}
if(i==)
{
while(j>)
{
c[++k]=(p+b[--j]-'')%+'';
p=(p+b[j]-'')/;
}
break;
}
if(j==)
{
while(i>)
{
c[++k]=(p+a[--i]-'')%+'';
p=(p+a[i]-'')/;
}
break;
}
i--,j--,k++;
}
printf("Case %d:\n",T1-T);
for(i=;i<alen;i++)
printf("%c",a[i]);
printf(" + ");
for(i=;i<blen;i++)
printf("%c",b[i]);
printf(" = ");
for(i=k;i>=;i--)
printf("%c",c[i]);
if(T>)
printf("\n\n");
else
printf("\n");
}
}
A+B II的更多相关文章
- Leetcode 笔记 113 - Path Sum II
题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...
- Leetcode 笔记 117 - Populating Next Right Pointers in Each Node II
题目链接:Populating Next Right Pointers in Each Node II | LeetCode OJ Follow up for problem "Popula ...
- 函数式Android编程(II):Kotlin语言的集合操作
原文标题:Functional Android (II): Collection operations in Kotlin 原文链接:http://antonioleiva.com/collectio ...
- 统计分析中Type I Error与Type II Error的区别
统计分析中Type I Error与Type II Error的区别 在统计分析中,经常提到Type I Error和Type II Error.他们的基本概念是什么?有什么区别? 下面的表格显示 b ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- [LeetCode] Guess Number Higher or Lower II 猜数字大小之二
We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to gues ...
- [LeetCode] Number of Islands II 岛屿的数量之二
A 2d grid map of m rows and n columns is initially filled with water. We may perform an addLand oper ...
- [LeetCode] Palindrome Permutation II 回文全排列之二
Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...
- [LeetCode] Permutations II 全排列之二
Given a collection of numbers that might contain duplicates, return all possible unique permutations ...
- History lives on in this distinguished Polish city II 2017/1/5
原文 Some fresh air After your time underground,you can return to ground level or maybe even a little ...
随机推荐
- Sumblime Text 2 常用插件以及安装方法
1.直接安装 安装Sublime text 2插件很方便,可以直接下载安装包解压缩到Packages目录(菜单->preferences->packages). 2.使用Package C ...
- 使用ARM模板部署自动扩展的Linux VMSS(2)
12.准备完了模板文件,我们使用Powershell来创建VMSS for Linux的自动扩展集合,首先登陆到Azure中国的ARM账号: Login-AzureRmAccount -Environ ...
- VS2005快捷键
VS2005快捷键 CTRL + SHIFT + B生成解决方案 CTRL + F7 生成编译 CTRL + O 打开文件 CTRL + SHIFT + O打开项目 CTRL + SHIFT + C显 ...
- RHEL 7.0 修改防火墙配置
RHEL 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 关闭firewall: systemctl stop firewalld.service #停止firewal ...
- 理解JMS规范中消息的传输模式和消息持久化
http://blog.csdn.net/aitangyong/article/category/2175061 http://blog.csdn.net/aitangyong/article/det ...
- hdu 1466 计算直线的交点数
http://acm.hdu.edu.cn/showproblem.php?pid=1466 N条直线的交点方案数 = c 条直线交叉的交点数与(N-c)条平行线 + c 条直线本身的交点方案 = ( ...
- JavaScriptSerializer类 对象序列化为JSON,JSON反序列化为对象
JavaScriptSerializer 类由异步通信层内部使用,用于序列化和反序列化在浏览器和 Web 服务器之间传递的数据.说白了就是能够直接将一个C#对象传送到前台页面成为javascript对 ...
- Linux APP源码级编译安装
首先需要了解下tar包. 以下文章作出解释了: http://www.cnblogs.com/laipDIDI/articles/2214270.html http://baike.baidu.com ...
- 【HDU 5510 Bazinga】字符串
2015沈阳区域赛现场赛第2题 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510 题意:给定一个由字符串组成的序列,一共n个元素,每个元素是一个不 ...
- canvas动画文字效果
Doughnut Chartvar c=document.getElementById("canvas");var ctx=c.getContext("2d") ...