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. 使用NPOI将数据库里信息导出Excel表格并提示用户下载

    使用NPOI进行导出Excel表格大家基本都会,我在网上却很少找到导出Excel表格并提示下载的 简单的代码如下 //mvc项目可以传多个id以逗号相隔的字符串 public ActionResult ...

  2. [TYVJ] P1004 滑雪

    滑雪   背景 Background 成成第一次模拟赛 第三道   描述 Description     trs喜欢滑雪.他来到了一个滑雪场,这个滑雪场是一个矩形,为了简便,我们用r行c列的矩阵来表示 ...

  3. 浅谈HashMap的实现原理

    1.    HashMap概述: HashMap是基于哈希表的Map接口的非同步实现.此实现提供所有可选的映射操作,并允许使用null值和null键.此类不保证映射的顺序,特别是它不保证该顺序恒久不变 ...

  4. 分布式文件系统 fastDFS 安装步骤

    安装 fastDFS 很简单. 先安装 libevent, 安装成功后,安装fastDFS. ./make.sh ./make.sh install 我使用一台tracker服务器  192.168. ...

  5. T-SQL 创建、修改、删除数据库,表语法

    CREATE 语句 CREATE语句的开头都是一样的,然后是特定的细节. CREATE <object type> <object name> 一.CREATE DATABAS ...

  6. svn小技巧——重定向svn diff

    svn diff的默认输出模式比较冗长,如果遇到修改比较多的情况,有时会较难看清diff.svn本身提供了自定义diff输出的选项,可能的修改方法如下: 建立一个脚本文件(如svndiff.sh),调 ...

  7. HDU1232 畅通工程 (并查集模板题)

    畅通工程 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  8. DWR常用<init-param>参数

    1 安全参数 allowGetForSafariButMakeForgeryEasier 开始版本:2.0 默认值:false 描述:设置成true使DWR工作在Safari 1.x , 会稍微降低安 ...

  9. Linux中shell文件操作大全

    1.创建文件夹#!/bin/shmkdir -m 777 "%%1" 2.创建文件#!/bin/shtouch "%%1" 3.删除文件#!/bin/shrm ...

  10. poj 2356 Find a multiple(鸽巢原理)

    Description The input contains N natural (i.e. positive integer) numbers ( N <= ). Each of that n ...