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. atom写文档技巧

    1. 段落和标题大纲 标题大纲(类似于HTML的H1, H2, …) 简单得很,一级标题用# 标题, 二级标题用## 标题,三级标题用### 标题,以此类推. 段落(类似HTML的<p>) ...

  2. dede调用指定栏目的标签

    {dede:type typeid='1'} <a href="[field:typelink /]">[field:typename /]</a> {/d ...

  3. [原]用C#模拟实现扑克牌发牌、排序程序。

    (1)52张扑克牌,四种花色(红桃.黑桃.方块和梅花),随机发牌给四个人. (2)最后将四个人的扑克牌包括花色打印在控制台上. 其中:     花色和点数用枚举类型实现     每张扑克牌用结构实 ...

  4. c++基础五个题(二)

    一.c++中static的作用 1.隐藏:当同时编译多个文件时,所有未加static前缀的全局变量和函数都具有全局可见性,static函数作用就是为了隐藏 2.可以保持变量的持久:存储在静态数据区的变 ...

  5. 利用fiddler录制脚本

    特性说明: 版本:V4.4 用途:将fiddler抓取的请求,导出为jmx格式,方便jmeter直接调用 新增功能: 1.在测试计划下,新增[HTTP请求默认值],内容为空,后续需将站点的IP和端口填 ...

  6. socket浅谈

    1什么是socket? socket的英文原义是“孔”或“插座”.作为进程通信机制,取后一种意思. 通常也称作“套接字”,用于描述IP地址和端口,是一个通信链的句柄. (其实就是两个程序通信用的.)是 ...

  7. 十、装饰(Decorator)模式 --结构模式(Structural Pattern)

    装饰(Decorator)模式又名包装(Wrapper)模式[GOF95].装饰模式以对客户端透明的方 式扩展对象的功能,是继承关系的一个替代方案. 装饰模式类图: 类图说明: 抽象构件(Compon ...

  8. USB系列之三:从你的U盘里读出更多的内容

    U盘是我们最常使用的一种USB设备,本文继续使用DOSUSB做驱动,试图以读取扇区的方式读取你的U盘.本文可能涉及的协议可能会比较多. 一.了解你的U盘    首先我们用上一篇文章介绍的程序usbvi ...

  9. Android EditText圆角的方法

    一.在drawable下面添加xml文件rounded_editview.xml <?xml version="1.0" encoding="utf-8" ...

  10. java中classPath和Xpath问题

    java中classPath和Xpath问题 今天遇到一个问题想获取classpath对应的目录,开始还以为java源代码可以像spring配置文件.xml中一样通过classpath:来获取对应的路 ...