当前位置:网站首页>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;
}
边栏推荐
- 定位position(5种方式)
- To make pytorch faster, you need to master these 17 methods
- Add the resources directory under test in idea
- Kubernetes understands kubectl/ debugging
- What moment makes you think there is a bug in the world?
- Clinical Chemistry | 张建中/徐健开发幽门螺杆菌单细胞精准诊疗技术
- 【中国海洋大学】考研初试复试资料分享
- Deploy eve-ng with KVM virtualization
- API encapsulation of uniapp applet
- Common classes in QT
猜你喜欢

分享自己平時使用的socket多客戶端通信的代碼技術點和軟件使用

15 -- 最接近原点的 K 个点

弹性布局(display:flex;)属性详解

API encapsulation of uniapp applet

How to combine multiple motion graphs into a GIF? Generate GIF animation pictures in three steps

合宙Air32F103CBT6开发板上手报告

What moment makes you think there is a bug in the world?

【Try to Hack】vulnhub DC1

About the problem of kicad stuck in win10 version, version 6 x

JS recursion and while
随机推荐
Output 0 ~ n digits and output multiple times
15 -- 最接近原点的 K 个点
How to combine multiple motion graphs into a GIF? Generate GIF animation pictures in three steps
定位position(5种方式)
How to cut the size of a moving picture? Try this online photo cropping tool
[untitled]
Use Matplotlib to draw a line chart
【深度学习】多任务学习 多个数据集 数据集漏标
如何裁剪动图大小?试试这个在线照片裁剪工具
Is it safe to open an online stock account? Who knows
To make pytorch faster, you need to master these 17 methods
从408改考自主命题,211贵州大学考研改考
Real variable instance
Remove interval (greedy)
【中国海洋大学】考研初试复试资料分享
Flexible layout (display:flex;) Attribute details
PubSub JS library realizes "cross component" data transfer
Clinical chemistry | zhangjianzhong / Xu Jian develop single cell precision diagnosis and treatment technology for Helicobacter pylori
现在股票开户用什么app最安全?知道的给说一下吧
ffmpeg protocol concat 进行ts流合并视频的时间戳计算及其音画同步方式一点浅析