C 高精度運算

2021-10-02 20:54:10 字數 1169 閱讀 5292

高精度加法

vector<

int>

add(vector<

int>

&a, vector<

int>

&b)if

(t) c.

push_back(1

);return c;

}

高精度減法
//判斷a b 的大小, 保證函式裡面是大的減小的

bool

cmp(vector<

int>

&a, vector<

int>

&b)vector<

int>

add(vector<

int>

&a, vector<

int>

&b)while

(c.size()

>

1&& c.

back()

==0) c.

pop_back()

;return c;

}

3.高精度乘低精度

vector<

int>

mul(vector<

int>

&a,int b)

if(t) c.

push_back

(t);

/* 如果這裡b是》10的數, 就寫成

while(t)

*/return c;

}

4.高精度除低精度

a除b餘r

vector<

int>

div(vector<

int>

&a,int b,

int&r)

r = t;

reverse

(c.begin()

, c.

end())

;while

(c.size()

>

1&& c.

back()

==0) c.

pop_back()

;return c;

}

高精度運算

今天覆習了一下高精度運算。我覺得這種簡單的東西也得看一看,至少給自己留點兒低!高精度可以壓位的,但我今年懶得寫了 首先是加減法很簡單了,沒什麼值得特別強調的。高精度減法時別忘了,a時做下交換在計算,輸出時別忘了標記負號。高精度乘法需要注意的問題是,要在做完乘法之後再調整為十進位制。有的初學者小盆友喜...

高精度運算

雖說高精度直接考查的越來越少,不過還是以防萬一。define maxlen 1000 struct bint 本模板既可輸入字串,也可輸入整數 bint int t if len 1 len bint char str print number friend void print bint bi p...

高精度運算

name 高精度運算 author goal00001111 date 01 12 08 15 04 description 高精度運算 加減乘除,乘方,階乘 include include using namespace std void reverse string str void addin...