POJ 2602 Superlong sums G++
来源:互联网 发布:mac万得股票机构 编辑:程序博客网 时间:2024/06/08 01:01
#include <cstdio>using namespace std;//谢谢博友文章 char a[1000000];char b[1000000];char c[1000000];int main(){int NUM;scanf("%d ",&NUM);for(int i=0;i<NUM;i++){//a[i]=getchar();//getchar();//b[i]=getchar();//getchar();scanf(" %c %c",&a[i],&b[i]);}int jw=0;for(int i=NUM-1;i>=0;i--){c[i]=(jw+a[i]-'0'+b[i]-'0')%10+'0';jw=(jw+a[i]-'0'+b[i]-'0')/10;}if(jw==1){printf("%c",'1');}printf("%s",c);/*for(int i=0;i<NUM;i++){//printf("%c",c[i]);putchar(c[i]);}*/return 0;}
#include <cstdio>using namespace std;//谢谢博友程序 //getchar(),putchar()比scanf和printf快。char a[1000000];char b[1000000];char c[1000000];int main(){int NUM;scanf("%d ",&NUM);for(int i=0;i<NUM;i++){a[i]=getchar();getchar();b[i]=getchar();getchar();//scanf(" %c %c",&a[i],&b[i]);}int jw=0;for(int i=NUM-1;i>=0;i--){c[i]=(jw+a[i]-'0'+b[i]-'0')%10+'0';jw=(jw+a[i]-'0'+b[i]-'0')/10;}if(jw==1){printf("%c",'1');}for(int i=0;i<NUM;i++){//printf("%c",c[i]);putchar(c[i]);}return 0;}
已知两个N位十进制数,求和。分别给出两个数从首位到末位相应位上的数字,位数不够时补零。
阅读全文
0 0
- POJ 2602 Superlong sums G++
- POJ 2602 Superlong sums
- POJ 2602Superlong sums
- POJ 2602 Superlong sums
- poj-2602-Superlong sums
- poj 大数 - 2602 Superlong sums
- POJ 2602 Superlong sums 大整数求和
- 北大ACM POJ 2602 Superlong sums
- Poj 2602 Superlong sums(大数相加)
- POJ 2602 Superlong sums (高精度,模拟,水题)
- Poj OpenJudge 百练 2602 Superlong sums
- POJ 2602 Superlong sums(模拟大数加法)
- POJ 2602 Superlong sums(高精度)
- POJ 2602|URAL 1048|Superlong Sums|高精度加法
- 北大 ACM 2602 Superlong sums
- POJ2602 Superlong sums
- ural 1048 Superlong Sums
- Poj2602 Superlong sums
- springmvc-web.xml无法映射的问题解惑
- 19th 【最短路 floyd】租用游艇
- Go语言学习之signal(二)
- java中的native方法
- shell基础
- POJ 2602 Superlong sums G++
- 获取网易云音乐封面图片
- 12-1-系统状态检测进程控制
- 【MyBatis学习15】MyBatis的逆向工程生成代码
- SAPUI5教程——The project is corrupted because its '.user.project.json' file has an invalid JSON
- 数据库拆分的问题
- 湘潭CCPC A题
- linux备忘
- ZKW,SPFA费用流模板