Problem Description
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.
 
Input
The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.
 
Output
For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.
 
Sample Input
2
1 2
112233445566778899 998877665544332211
 
Sample Output
Case 1: 1 + 2 = 3
Case 2: 112233445566778899 + 998877665544332211 = 1111111111111111110
 #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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 函数式Android编程(II):Kotlin语言的集合操作

    原文标题:Functional Android (II): Collection operations in Kotlin 原文链接:http://antonioleiva.com/collectio ...

  4. 统计分析中Type I Error与Type II Error的区别

    统计分析中Type I Error与Type II Error的区别 在统计分析中,经常提到Type I Error和Type II Error.他们的基本概念是什么?有什么区别? 下面的表格显示 b ...

  5. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  6. [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 ...

  7. [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 ...

  8. [LeetCode] Palindrome Permutation II 回文全排列之二

    Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...

  9. [LeetCode] Permutations II 全排列之二

    Given a collection of numbers that might contain duplicates, return all possible unique permutations ...

  10. 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 ...

随机推荐

  1. [C++程序设计]用指向数组的指针作函数参数

    #include <iostream> using namespace std; int main() { ]); ][]={,,,,,,,,,,,}; output(a); ; } ]) ...

  2. [C++程序设计]对“&”和“*”运算符

    对“&”和“*”运算符再做些说明:(1) 如果已执行了“pointer_1=&a;”语句,请问&*pointer_1的含义是什么?“&”和“*”两个运算符的优先级别相同 ...

  3. 网易2014校园招聘杭州Java笔试题

    10) ABC http://soft.chinabyte.com/os/56/12516056.shtml 11) BD. 12) AC. http://blog.sina.com.cn/s/blo ...

  4. 十一、外观(Facade)模式--结构模式(Structural Pattern)

    外部与一个子系统的通信必须通过一个统一的门面(Facade)对象进行,这就是门面模式.门面模式要求一个子系统的外部与其内部的通信必须通过一个统一的门面(Facade)对象进行. 门面模式提供一个高层次 ...

  5. BZOJ 3572 世界树(虚树)

    http://www.lydsy.com/JudgeOnline/problem.php?id=3572 思路:建立虚树,然后可以发现,每条边不是同归属于一端,那就是切开,一半给上面,一半给下面. # ...

  6. 找不到Qt5Cored.dll(Release和Debug版连接了不同的库)

    Qt5Cored.dll和Qt5Core.dll文件分别用于Qt软件的Debug版和Release版. 通常会有两个Qt5Core.dll文件,分别位于Qti安装目录下的“Qt5.1.0\5.1.0\ ...

  7. TCP Keepalive HOWTO

    TCP Keepalive HOWTO Fabio Busatto <fabio.busatto@sikurezza.org> 2007-05-04 Revision History Re ...

  8. android系统的图片资源

    使用系统的图片资源的好处有,一个是美工不需要重复的做一份已有的图片了,可以节约不少工时:另一个是能保证我们的应用程序的风格与系统一致. 1.引用方式 在源代码*.Java中可以进入如下方式引用: my ...

  9. 解决cognos以远程db2数据库为数据源的连接失败问题

    问题现象为使用远程的db2来创建数据源时,测试连接时不通,好多人都说是驱动问题,将db2cc.jar拷贝到某lib目录下,实验不通: 在看到某哥们的博客时最后提了一句,说需要将数据库catalog到本 ...

  10. unmount的时候报错

    卸载存储的时候报错 device is busy 解决办法 例:/mnt/test 为存储挂载点 fuser -m -v /mnt/test fuser 可以显示出当前哪个程序在使用磁盘上的某个文件. ...