A+B=?
2016-05-26 21:13
155 查看
题目简介:大数相加
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
代码:
{
int i, r, sum, len1=strlen(str1), len2=strlen(str2);
strrev(str1), strrev(str2); //翻转字符数组;
for(i=0,r=0;i
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”
void SUM(char str1[], char str2[], char str3[]){
int i, r, sum, len1=strlen(str1), len2=strlen(str2);
strrev(str1), strrev(str2); //翻转字符数组;
for(i=0,r=0;i
相关文章推荐
- [SQL]语法总结
- 文件系统-硬链接与软链接的区别
- 移动开发者的成长之路?
- hihocoder 1068 ST算法java实现
- Spark Streaming源码解读之State管理之updateStateByKey和mapWithState解密
- android wear 相关素材
- 读《构建之法》第8、9、10章有感
- BZOJ 4596: [Shoi2016]黑暗前的幻想乡
- C++ ,预测身高程序
- Leetcode no. 110
- exec()函数
- node前端自动化
- # USACO4.4 三道题
- cf#354
- 链表,纠错!
- 最可怕的是牛人还那么努力
- Linux grep用法整理
- C++面试笔记--STL模板与容器
- 随手摘录
- 应用类App框架搭建 之框架分析(待续)