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 ...
随机推荐
- Onthink_项目后总结
---------------------------------------写代码不孤独__小小代(http://www.cnblogs.com/xiaoxiaodai/) 经过一段时间的沉寂,项目 ...
- BZOJ 2440 完全平方数(莫比乌斯反演,容斥原理)
http://www.lydsy.com/JudgeOnline/problem.php?id=2440 题意:求第K个没有平方因子的数 思路:首先,可以二分数字,然后问题就转变成x以内有多少无平方因 ...
- 数据类型MSVC和gcc/g++的不同
前言: 在16位环境下,int/unsigned int 占16位,long/unsigned long占32位 在32位环境下,int占32位,unsigned int占16位,long/unsig ...
- 软件架构 "4+1" 视图模型
1995年,Philippe Kruchten在<IEEE Software>上发表了题为<The 4+1 View Model of Architecture>的论文,引起了 ...
- UESTC_邱老师看电影 2015 UESTC Training for Dynamic Programming<Problem F>
F - 邱老师看电影 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submi ...
- k-d Tree in TripAdvisor
Today, TripAdvisor held a tech talk in Columbia University. The topic is about k-d Tree implemented ...
- pktgen使用详细教程
网上有很多讲解pktgen的文章,但总是不够全面细致,看完之后自己还是不会写pktgen测试脚本,为此本文对pktgen进行详细的阐述,让大家看完本文后能够自己动手写pktgen shell. 1.p ...
- Unity 编辑器扩展自定义窗体
这次看见Unity还可以自定义弹出窗体,让我很好奇.于是就去网上找文章看了看. 如果想自定义窗体需要把类放入Editor文件夹下面. 代码如下: using UnityEngine; using Un ...
- IOS开发之---触摸和手势
Touch:在与设备的多点触摸屏交互时生成. 响应者对象 响应者对象就是可以响应事件并对事件作出处理.在iOS中,存在UIResponder类,它定义了响应者对象的所有方法.UIApplication ...
- 认识SVN
TortoiseSVN 是 Subversion 版本控制系统的一个免费开源客户端,可以超越时间的管理文件和目录.文件保存在中央版本库,除了能记住文件和目录的每次修改以外,版本库非常像普通的文件 服务 ...