title: 大数加法减法乘法除法模板(C++,Python)
categories:
- OJ
- 算法
- Python
- C++
tags:
- Programing
- OJ
- 算法
- Python
- C++
大数加法减法乘法除法模板(C++,Python)
C++
加法
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
string BigNumberAdd(){
string s1,s2,result(10000,'0');
cin>>s1>>s2;
reverse(s1.begin(),s1.end());
reverse(s2.begin(),s2.end());
for(int i=0;i<s1.length();i++){
result[i] = s1[i];
}
int temp = 0;
for(int i=0;i<s2.length();i++){
temp += (result[i]-'0' + s2[i] -'0');
result[i] = temp%10 + '0';
temp /= 10;
}
result[s2.length()]