当前位置:网站首页>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;
}
边栏推荐
- For the first time in China, Chinatelecom 5g underground personnel positioning project is officially commercial: it can track the position in real time to ensure operation safety
- From 408 to independent proposition, 211 to postgraduate entrance examination of Guizhou University
- C language escape character and its meaning
- 分享自己平時使用的socket多客戶端通信的代碼技術點和軟件使用
- Go语言Zap库Logger的定制化和封装使用详解
- JS floating point multiplication and division method can not accurately calculate the problem
- 2020-03-20
- HMS core machine learning service realizes simultaneous interpretation, supports Chinese-English translation and multiple voice broadcast
- Dmsetup command
- Does stream even have application advanced learning? As a programmer, you know what
猜你喜欢

Uniapp cloud packaging app

Does stream even have application advanced learning? As a programmer, you know what

SPARQL learning notes of query, an rrdf query language

Summary of common functions in Oracle Database

In 2022, the score line of Guangdong college entrance examination was released, and several families were happy and several worried

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

搭建极简GB28181 网守和网关服务器,建立AI推理和3d服务场景,然后开源代码(一)

有哪个瞬间让你觉得这个世界出bug了?

oracle数据库常用的函数总结
![[untitled] the CMD command window displays' NPM 'which is not an internal or external command](/img/db/b1ae4b0d1110af1e24887ba3b4fe16.jpg)
[untitled] the CMD command window displays' NPM 'which is not an internal or external command
随机推荐
买卖股票的最佳时机
如何裁剪动图大小?试试这个在线照片裁剪工具
JGG | overview of duhuilong group of Hebei University Research on plant pan genomics
Native JS obtains form data and highlights and beautifies JSON output display
【Try to Hack】vulnhub DC1
Yolov3 spp Darknet version to caffemodel and then to OM model
Function of getinstance() method
Usage of pure virtual functions
QT database connection deletion
Variables, scopes, and variable promotion
[Ocean University of China] Data Sharing for retest of initial Examination
Master XSS completely from 0 to 1
当了六年程序员第一次搞懂微服务架构的数据一致性,真不容易
Extend JS copy content to clipboard
买基金在哪里开户安全?求指导
搭建极简GB28181 网守和网关服务器,建立AI推理和3d服务场景,然后开源代码(一)
Is it normal to dig for money? Is it safe to open a stock account?
ffmpeg protocol concat 进行ts流合并视频的时间戳计算及其音画同步方式一点浅析
Get the parameters in the URL and the interchange between parameters and objects
合宙Air32F103CBT6开发板上手报告