#include <stdio.h>
#include <string.h>
int main(void)
{
int q,j,h,k,l;
int d;
char s1[],s2[];//题目要求位数不大于1000
scanf("%d",&h);
for(l=;l<=h;l++){
int c[]={}, a[]={},b[]={};//这样可以令数组内全部元素为0
scanf("%s %s",&s1,&s2);
int cd1,cd2,cd3,cdmax,cdmin;
cd1=strlen(s1);
cd2=strlen(s2);
cdmax=cd1>cd2?cd1:cd2;
for(q=,j=cd1;q<cd1;q++,j--)
a[q]=s1[j-]-;
for(q=,j=cd2;q<cd2;q++,j--)
b[q]=s2[j-]-;
for(k=,d=;k<cdmax;k++)
{
c[k]=(a[k]+b[k]+d)%; //个个位相加满十进一
d=(a[k]+b[k]+d)/;
}
printf("Case %d:\n%s +%s =",l,s1,s2);
if(d!=){//判断最后一位和是否大于一
c[cdmax]=;
for(cd3=cdmax;cd3>=;cd3--){
printf("%d",c[cd3]);
}
}
else{
for(cd3=cdmax-;cd3>=;cd3--){
printf("%d",c[cd3]);
}
}
if(l!=h)//最后跳一行
printf("\n\n");
else
printf("\n");
}
return ;
}

题目:

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.
                        处理                                                                                                   1000以内 ,即使double longlong 也无法满足
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

方法步骤:将数字以字符串的方式存储,在单个位相加(用10取余),满十进一(除10),注意初始化(对前几位数赋值,后面直接默认赋0)

oj 1002题 (大数题)的更多相关文章

  1. PKU OJ 1002 487-3279

    PKU OJ 1002 487-3279 487-3279 Description Businesses like to have memorable telephone numbers. One w ...

  2. Educational Codeforces Round 12补题 经典题 再次爆零

    发生了好多事情 再加上昨晚教育场的爆零 ..真的烦 题目链接 A题经典题 这个题我一开始推公式wa 其实一看到数据范围 就算遍历也OK 存在的问题进制错误 .. 思路不清晰 两个线段有交叉 并不是端点 ...

  3. Web前端错题模糊题记录

    title: Web前端错题模糊题记录 toc: true date: 2018-09-20 10:04:36 categories: Web tags: HTML CSS JavaScript HT ...

  4. PMP全真模拟题真题試題含答案解析 2019年下半年PMP考試适用 PMP中文文对照试题 【香港台灣地區PMP考試也可用】

    PMP全真模拟题真题试题 含答案解析 2019年下半年PMP考试适用 PMP中文文对照试题 [香港台灣地區PMP考試也可用]PMP全真模擬題真題試題 含答案解析 2019年下半年PMP考試适用 PMP ...

  5. 九度oj 1002 Grading 2011年浙江大学计算机及软件工程研究生机试真题

    #include<iostream> #include<queue> #include<cstdio> #include<cstring> #inclu ...

  6. 各大Oj平台介绍 刷题平台

    https://leetcode.com/ http://www.cnblogs.com/lzmfywz/archive/2012/02/07/2342010.html 1.题库与网站资源题库-在线提 ...

  7. 华为OJ题目:刷题

    题目描述: 新入职华为的小伙伴们都有在oj上面刷题的任务,共需要刷100道初级题,45道中级题,5道高级题,其中,做出来的高级题如果超标可以当初级或者中级题,做出来的中级题如果超标可以当初级题.每天, ...

  8. 用python做oj上的简单题(持续更新中.......)

    本人刚開始接触python,在oj上解一些简单的题,欢迎交流,不喜勿喷. OJ地址链接:acm.sdut.edu.cn http://acm.sdut.edu.cn/sdutoj/showproble ...

  9. 剑指offer编程题Java实现——面试题12相关题大数的加法、减法、乘法问题的实现

    用字符串或者数组表示大数是一种很简单有效的表示方式.在打印1到最大的n为数的问题上采用的是使用数组表示大数的方式.在相关题实现任意两个整数的加法.减法.乘法的实现中,采用字符串对大数进行表示,不过在具 ...

随机推荐

  1. (经典)直接插入排序based on 二分查找

    #include<stdio.h> // 查找第一个大于key的元素,成功则返回该元素的下标,否则返回数组末元素的下一位 int findFirstLarger(int A[],int n ...

  2. Android SDK无法更新的问题解决办法

    问题: SSL hostname in certificate didn't matchhostname in certificate didn't match: <dl-ssl.google. ...

  3. 解决Mybatis没有代码提示

    MyBatis xml文件中代码自动提示 工具/原料   eclipse,maven 方法/步骤   1 一.获得mybatis-3-config.dtd.mybatis-3-mapper.dtd 这 ...

  4. postgresql双机热备、高可用方案(采用pacemaker+corosync实现)

    http://blog.csdn.net/qguanri/article/details/51151974 需求描述 我们有两台centos7的数据库主机A.B.要对A.B实现双机热备,A作为数据库m ...

  5. nginx禁止非sever_name指定域名访问

    禁止非sever_name指定域名访问,将其访问指向默认站点: 设置非server_name指定域名访问,将该访问重写到test.1comserver { listen 80 default; rew ...

  6. HttpHelp 请求帮助类

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...

  7. c# 爬虫(三) 文件上传

    在上一篇中,我们说了模拟登录, 下面我们说说附件上传. 据说,最早的http协议是不支持附件上传的,后来有添加了一个RFC 2045 协议,才支持附件上传,关于附件上传,请参见 http://www. ...

  8. HDU 2201 熊猫阿波的故事

    熊猫阿波的故事 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  9. Mysql插入数据报错java.sql.SQLException: Incorrect string value: '\xF0\x9F\x93\x8D\xE6\x88...'

    今天读取solr里面的数据,往mysql插入时报错, Incorrect string value: '\xF0\x9F\x93\x8D\xE8\x88...' for column 'title'  ...

  10. centos使用163 yum源

    备份# cp /etc/yum.repos.d/CentOS-Base.repo  /etc/yum.repos.d/CentOS-Base.repo.bak修改# vi /etc/yum.repos ...