高精度加法
2017-01-19 15:16
155 查看
高精度加法
C语言版#include<stdio.h> #include<string.h> void high_accuracy(char *a,char *b){ int m,n,i=0,p=0; char c[1001]; m=strlen(a)-1; n=strlen(b)-1; for(i=0;m>=0||n>=0;i++,m--,n--){ if(m>=0&&n>=0) c[i]=a[m]+b -'0'+p; if(m>=0&&n<0) c[i]=a[m]+p; if(m<0&&n>=0) c[i]=b +p; p=0; if(c[i]>'9') { c[i]=c[i]-10; p=1; } } if(p==1) printf("1"); while(i--){ printf("%c",c[i]); } } int main(){ char a[1000]={'\0'},b[1000]={'\0'}; scanf("%s %s",a,b); high_accuracy(a,b); return 0; }
相关文章推荐
- 蓝桥杯 基础练习 高精度加法
- 高精度整数(n进制,n<=10)加法
- 华为oj中级 高精度加法
- 高精度加法模板
- 华为上机-要求编程实现上述高精度的十进制加法。要求实现函数: void add (const char *num1, const char *num2, char *result)
- java蓝桥杯试题高精度加法函数实现
- A+B problem (压8位高精度加法模板)
- 蓝桥杯-基础训练VIP - 高精度加法
- 用C++实现高精度加法
- 高精度处理大数加法C语言实现
- 高精度运算专题1-加法运算(The addition operation)
- 高精度加法
- 【CODEVS3116】高精度练习之加法
- [原创]10^9进制高精度大整数加法(MMX版本)
- 3116 高精度练习之加法——http://codevs.cn/problem/3116/
- 高精度加法
- C++的高精度整数加法运算算法
- pku1737(求连通图个数,运用高精度加法,减法,乘法,组合数)
- 第一篇、C_高精度加法
- 高精度计算----加法