高精度加法

2021-08-14 21:42:10 字數 583 閱讀 3924

覺得字串寫的不好。。。就試著寫寫字串。。。

然後。。。莫名想起高精度。。。

好吧寫高精度。。。

感覺寫的比較。。。

不支援負數,最大兩萬位。。。

(當然改幾個數就可以幾十萬位。。。)

上**基本思路:

先讀入,然後字元轉換成數字(減0)(注意是字串加減啊)

再把短的前面補零跟長的對齊,加起來,滿十進一。

就可以了、、、

#include #include #include using namespace std;

char s1[20000];

char s2[20000];

int num1[20000], len1;

int num2[20000], len2;

int main()

len1 = len;

if(num1[len+1])

len1++;

for(int i=len1; i>=1; i--)

printf("%d", num1[i]);

return 0;

}

python高精度加法 高精度加法

1.思路 其實就是模擬,加法是最簡單的,從個位開始加,價位加到前一位,然後再取10的餘數。for int i 1 i len i 計算和 c i a i b i 進製 c i 1 c i 10 取10的餘數 c i 10 2.實現 int len max a.length b.length 倒著存,...

高精度加法 高精度減法

雖然以前自己就學習過,但是自己打出來的 目測效率不高,也不夠精簡 因此學習一下eden裡面的這一題 big integer add subtract ifndef big integer define big integer include include using std string usin...

高精度加法

program gjplus vars1,s2,s3,st,s string i,j,k,l1,l2,li,n1,n2,n3,n4 integer begin readln s1 readln s2 l1 length s1 l2 length s2 if l1 l2 then li l1 else...