資源簡介
GarbaGe的東西降價了!!!一分,就一分!!!好東西一定要分享啊啊啊!!!
本模板為高精度模板,大概可存儲200位。
目前只支持:輸入、輸出、賦值、加法。
會不定期更新,請多多資瓷!
代碼片段和文件信息
#include
#include
#include
#include
using?namespace?std;
struct?BigInteger?{
??static?const?int?base?=?100000000;
??static?const?int?WIDTH?=?8;
??vector?s;
??BigInteger(long?long?num?=?0)?{?*this?=?num;?}?//?構造函數
??BigInteger?operator?=?(long?long?num)?{?//?賦值運算符
????s.clear();
????do?{
??????s.push_back(num?%?base);
??????num?/=?base;
????}?while(num?>?0);
????return?*this;
??}
??BigInteger?operator?=?(const?string&?str)?{?//?賦值運算符
????s.clear();
????int?x?len?=?(str.length()?-?1)?/?WIDTH?+?1;
????for(int?i?=?0;?i???????int?end?=?str.length()?-?i*WIDTH;
??????int?start?=?max(0?end?-?WIDTH);
??????sscanf(str.substr(start?end-start).c_str()?“%d“?&x);
??????s.push_back(x);
????}
????return?*this;
??}
- 上一篇:DAC8552生成正弦波程序
- 下一篇:猜數游戲。c語言
評論
共有 條評論