poj1503
来源:互联网 发布:初学美工要会哪些软件 编辑:程序博客网 时间:2024/05/17 04:38
#include <iostream>#include <stdio.h>#include <cstring>#include <memory.h>using namespace std;int main(){ int a[20000],b[20000],i,l1,l2; char s1[200],s2[200]; //freopen("in.txt","r",stdin); memset(a,0,sizeof(a)); scanf("%s",s1);l1=strlen(s1); if (s1[0]=='0') {cout<<'0';return 0;} for (i=1;i<=l1;i++) a[i]=s1[l1-i]-'0'; scanf("%s",s2); while ((s2[0]!='0')||(strlen(s2)>1)) { memset(b,0,sizeof(b)); l2=strlen(s2); for (i=1;i<=l2;i++) b[i]=s2[l2-i]-'0'; if (l2>l1) l1=l2; for (i=1;i<=l1;i++) a[i]+=b[i]; for (i=1;i<=l1;i++) { a[i+1]+=a[i]/10; a[i]=a[i]%10; } while (a[l1+1]>0) l1++; scanf("%s",s2); } for (i=l1;i>=1;i--) cout<<a[i]; return 0;}
【题意】
给定不超过100个不超过100位的正整数,求和
【输入】
每行一个数
数据以一行0结束
【输出】
输出所有数的和
高精度加法
0 0
- poj1503
- poj1503
- poj1503
- poj1503
- poj1503
- poj1503
- POJ1503
- POJ1503
- poj1503
- POJ1503
- poj1503
- poj1503
- POJ1503
- POJ1503
- poj1503 高精度
- POJ1503解题报告
- POJ1503 Integer Inquiry
- poj1503 大数相加
- Learning_Android第二版Tweet程序项目设计图
- [面试时]我是如何讲清楚TCP/IP是如何实现可靠传输的
- Python]网络爬虫
- LINUX下gdb调试(转载)
- 从telnet www.baidu.com 80 聊聊我经历过的tcp“三次握手”失败---顺便验证telnet是基于tcp协议的
- poj1503
- ryjrdyj
- 游戏服务器中的日志处理方式之一
- hdu1711
- java(引入一个中间变量,不引入中间变量)交换两个变量的值
- Merge k Sorted Lists -- LeetCode
- 设置ActionBar的背景色
- Java复习笔记2【next()和nextLine()】
- Java的可变参数,参数后面三个点