当前位置:网站首页>High precision addition
High precision addition
2022-06-25 14:50:00 【䨁 逦】
#include<stdio.h>
#include<string.h>
int max(int a,int b)
{
if(a>b) return a;
else return b;
}
char s1[505],s2[505];
int a[505],b[505],c[505];
int main(){
int la,lb,lc;
scanf("%s",s1);
scanf("%s",s2);
la=strlen(s1);
lb=strlen(s2);
for(int i=0;i<=la;i++)
{
a[la-i]=s1[i]-'0';
}//½«×Ö·ûת»¯ÎªÊý×Ö
for(int i=0;i<=lb;i++)
{
b[lb-i]=s2[i]-'0';
}
lc=max(la,lb)+1;
for(int i=1;i<=lc;i++)
{
c[i]+=a[i]+b[i];
c[i+1]=c[i]/10;//ºËÐÄËã·¨
c[i]=c[i]%10;
}
if(c[lc]==0&&lc>0) lc--;//Åųýǰµ¼0
for(int i=lc;i>0;i--)
{
printf("%d",c[i]);
}
return 0;
}
边栏推荐
- JS get the height and width corresponding to the box model (window.getcomputedstyle, dom.getboundingclientrect)
- oracle数据库常用的函数总结
- [deep learning] multi task learning of multiple datasets data sets missing labels
- To make pytorch faster, you need to master these 17 methods
- What moment makes you think there is a bug in the world?
- Biscuit distribution
- 2020-03-20
- Gif动画怎么在线制作?快试试这款gif在线制作工具
- Using Sphinx to automatically generate API documents from py source files
- JS floating point multiplication and division method can not accurately calculate the problem
猜你喜欢

Clinical Chemistry | 张建中/徐健开发幽门螺杆菌单细胞精准诊疗技术

【Try to Hack】vulnhub DC1

Share the code technology points and software usage of socket multi client communication

Uniapp icon configuration

Ideal L9 in the eyes of the post-90s: the simplest product philosophy, creating the most popular products

Two methods to rollback the code in pycharm to the specified version (with screenshot)

JS recursion and while

15 -- k points closest to the origin

Power automatic test system nsat-8000, accurate, high-speed and reliable power test equipment

Renix perf: detailed explanation of IP network performance test tools and test case parameters
随机推荐
Gif动画怎么在线制作?快试试这款gif在线制作工具
How to cut the size of a moving picture? Try this online photo cropping tool
Master XSS completely from 0 to 1
How to combine multiple motion graphs into a GIF? Generate GIF animation pictures in three steps
API encapsulation of uniapp applet
Real variable instance
Gif动图如何裁剪?收下这个图片在线裁剪工具
HMS Core机器学习服务实现同声传译,支持中英文互译和多种音色语音播报
Using Sphinx to automatically generate API documents from py source files
Summary of common functions in Oracle Database
【中國海洋大學】考研初試複試資料分享
dev/mapper的解释
15 -- 最接近原点的 K 个点
90 后眼中的理想 L9:最简单的产品哲学,造最猛的爆款 | 指南斟
[Ocean University of China] information sharing for the first and second examinations of postgraduate entrance examination
About the problem of kicad stuck in win10 version, version 6 x
Thymeleaf Usage Summary
2020-03-20
oracle数据库常用的函数总结
China has made major breakthroughs in battery technology. Japan, South Korea and the United States are lagging behind. China has consolidated its leading edge