31 行代码C++课堂示例
高精度加法
两个高精度数相加的普通实现
#include<bits/stdc++.h>
using namespace std;
int main(){
string a,b;
cin>>a>>b;
//翻转对齐#高精度
两个高精度数相加的普通实现
#include<bits/stdc++.h>
using namespace std;
int main(){
string a,b;
cin>>a>>b;
//翻转对齐两个高精度数相减的普通实现(包括小减大)
#include<bits/stdc++.h>
using namespace std;
int main(){
string a, b;
cin >> a >> b;bigInt 大整数的结构体封装以及构造函数
struct bigInt {
int digit[1000] = {0}, len = 0;
// s 的默认值为 “0”,可以不用传参
bigInt (string s = "0") {
len = s.size();
for (int i = 0, j = len-1; i < len; i++, j--)包含了 bigInt 大整数的结构体封装,加法、高精度*单精度乘法、高精度*高精度乘法重载(不考虑负数)
#include <bits/stdc++.h>
using namespace std;
struct bigInt {
int digit[1000] = {0}, len = 0;
// s 的默认值为 “0”,可以不用传参