poj 1503 Integer Inquiry高精度
来源:互联网 发布:js textarea 不可编辑 编辑:程序博客网 时间:2024/06/04 19:13
以前一直坐高精度都养把倒置数组,看了别人的结题报告发现一个很好的方法,只要把数组向后移就行了
#include<iostream>
using namespace std;
#include<string.h>
#include<memory.h>
char a[101];
int main()
{
int M=109;
int N=108;
char b[109];
memset(b,48,sizeof(b));
while(cin>>a,strcmp("0",a)!=0)
{
int len=strlen(a);
for(int i=0;i<N;i++)//高精度加法新思想,好
{
if(i<len)
b[N-i-1]=b[N-i-1]+a[len-i-1]-48;
if(b[N-i-1]>=58)
{
b[N-i-1]-=10;
b[N-i-2]+=1;
}
}
}
int i;
for(i=0;i<N;i++)
{
if(b[i]!=48)
break;
}
b[N]='/0';
if(i==N)
cout<<0<<endl;
else
cout<<b+i<<endl;
// system("pause");
return 0;
}
- poj 1503 Integer Inquiry高精度
- poj 1503 Integer Inquiry【高精度】
- POJ 1503 Integer Inquiry 高精度
- POJ 1503 Integer Inquiry(高精度运算)
- POJ 1503 Integer Inquiry 高精度加法
- poj 1503Integer Inquiry(高精度 水题)
- POJ 1503 Integer Inquiry 高精度加法
- POJ 1503 Integer Inquiry(高精度)
- (高精度运算4.7.23)POJ 1503 Integer Inquiry(大数累加)
- POJ 1503 && HDU 1047 Integer Inquiry(高精度)
- POJ – 1503 Integer Inquiry Integer Inquiry
- POJ 1503 Integer Inquiry
- poj 1503 Integer Inquiry
- POJ 1503 Integer Inquiry
- poj 1503 Integer Inquiry
- POJ 1503 Integer Inquiry
- POJ 1503 Integer Inquiry
- POJ---1503 Integer Inquiry
- ISTQB FL初级认证系列01:ISTQB FL初级认证考试说明
- 关于linux下mmap的一点强调
- Hibernate ID 生成策略
- ASP.NET下CKEditor和CKFinder集成 配置
- 有关MAC、PHY和MII
- poj 1503 Integer Inquiry高精度
- 使用反射访问特性
- 气质的培养(哈佛管理世界)除了沉稳外很适合研发人员借鉴
- JSOI 2008-help
- Android布局之LinearLayout(线性布局)
- symbian程序安装时兼容第三版和第五版
- 如何使用Delphi编写Modbus RTU CRC16的校验码
- jquery之浏览器的事件模型(DOM 0级事件模型)
- 自定义数字排序(方法一)