题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=103

纯模拟,没啥好说的 - -

#include <cstdio>
#include <cstring>
#include <algorithm>using namespace std;char s[1010];
char s1[1005];
int s2[1005];
int len_s;
int len_s1;void Reverse(char s[],int len){for(int i = 0,j = len - 1;i < j && i < len / 2;++i,--j){char t = s[i];s[i] = s[j];s[j] = t;}}
int main(){int cnt = 1;int _;scanf("%d",&_);while(_--){memset(s2,0,sizeof(s2));scanf("%s%s",s,s1);len_s = strlen(s);len_s1 = strlen(s1);printf("Case %d:\n",cnt++);printf("%s + %s = ",s,s1);Reverse(s,len_s);Reverse(s1,len_s1);//printf("%s %s\n",s,s1);int c = 0;int i;for(i = 0;i < min(len_s,len_s1);++i){s2[i] = (s[i] - '0' + s1[i] - '0' + c) % 10;//printf("%d %d %d %d\n",s[i] - '0',s1[i] - '0',s2[i],s[i] - '0' + s1[i] - '0' + c);c = (s[i] - '0'+ s1[i] - '0' + c) / 10;}while(i < len_s){s2[i] = (s[i]  - '0' + c) % 10;c = (s[i] - '0' + c) / 10;i++;}while(i < len_s1){s2[i] = (s1[i] - '0' + c) % 10;c = (s1[i] - '0' + c) / 10;i++;}while(c){s2[i++] = c % 10;c /= 10;}for(int j = i - 1;j >= 0;--j)printf("%d",s2[j]);printf("\n");}return 0;
}

NYOJ103A+B Problem II相关推荐

  1. hdu A + B Problem II(大数相加,数组实现)

    hdu A + B Problem II(大数相加,数组实现) 题目走起 注意最后一个case 不需要换行 下面代码 #include<stdio.h> #include<strin ...

  2. HDU1002 Problem II(大数相加)(C++题解)

    A题 HDOJ1002(大数加法) A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/327 ...

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

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

  4. java棋盘问题_0x03大数问题(JAVA解决棋盘覆盖,A+B Problem II)

    常见的有棋盘覆盖和A+B问题,这类问题牵扯到的数值都比较大,如果用一般的数值类型,肯定输出不了,所以就要想一个办法,怎么把大数转换一下输出. A+B Problem II 时间限制:3000 ms | ...

  5. NYOJ 103 A+B Problem II

    A+B Problem II 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 I have a very simple problem for you. Given tw ...

  6. 专题突破一之分块——Untitled Problem II,Balanced Lineup,[ioi2009]Regions

    文章目录 SP2940 UNTITLE1 - Untitled Problem II source solution code Balanced Lineup source code Count on ...

  7. hdu 1023 Train Problem II

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...

  8. Train Problem II 卡特兰裸题(入门题)

    Train Problem II  题目大意:给你一个数n,表示有n辆火车,编号从1到n,从远方驶过来,问你有多少种出站的可能. 解题思路:模拟栈的问题而已.  卡特兰问题. 1 import jav ...

  9. HPU 1002 A + B Problem II【大数】

    HPU 1002 A + B Problem II[大数] A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limi ...

最新文章

  1. 【线上分享】基于CDN边缘网络智能优化图片和视频
  2. CAP 2.6 版本发布通告
  3. Spring+Quartz(一)
  4. python语言公式求圆周率_通过Python实现圆周率的计算(公式方法和蒙特卡罗方法)...
  5. 异常关闭MyEclipse 8.6后,不能重启
  6. php-学通PHP的24堂课-设置PHP的系统当前时间
  7. 前端工程师做事的三重境界:我的进阶之路
  8. report 和report on的区别
  9. 前后端分离项目部署_不用Docker前后端分离项目如何快速部署
  10. R语言-运筹学线性规划实例
  11. nodejs安装时遇到的问题及解决方案
  12. 我怎样从珍爱网拿回18800会员费:交友平台相亲不靠谱
  13. 播放和保存视频,图像倒置纠正到本地文件夹(含ffmpeg ,pyav多线程读取多路网络摄像头)
  14. 使用Canal ClientAdapter实现Mysql的DDL、DML同步到PostgreSQL
  15. 华为鲲鹏是芯片还是服务器,关于芯片:眼见为实华为鲲鹏架构服务器生态大揭秘...
  16. LSF_安装(UNIX or Linux)
  17. 某app登录协议逆向分析
  18. vs2019 加载.obj文件报错找不到403 IIS 3D可视化.obj/.mtl文件找不到
  19. 第五章 区块链应用的全球进展
  20. Android studio给备忘录添加背景音乐

热门文章

  1. ui设计新手入门学习需要注意什么细节
  2. 力扣 1816. 截断句子
  3. 随机森林分类预测(多棵树)
  4. 超简单的用C语言实现定时关闭计算机
  5. 成功项目管理三要素的平衡
  6. 包邮送88本畅销技术书
  7. ui字体 pt 和 前端字体 px 之间的转化
  8. 直播预告|数据湖实时化与智能化实践探索
  9. 【计算机网络】参数包含特殊字符导致导致Http Get 请求报错
  10. redis中的bitfield命令