大数运算(支持负号 乘法用分治法目前缺除法)(The operation of large numbers (support minus multiplication with the method currently lack of division)).docVIP
- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
大数运算(支持负号 乘法用分治法目前缺除法)(The operation of large numbers (support minus multiplication with the method currently lack of division))
大数运算(支持负号 乘法用分治法目前缺除法)(The operation of large numbers (support minus multiplication with the method currently lack of division))
/ / 旧弄;
/ / a = a1a0 = a1 * (10 ^ (n / 2)) + a0;
/ / b = b1b0 = b1 * (10 ^ (n / 2)) + b0;
/ / c = a * b = a1b1 * (10 ^ 2n) + [(a1b0 + b1a0) * (10 ^ n)] + a1b1
/ / c = a * b = c * (10 ^ 2n) + c1 * (10 ^ n) + c0;
/ / c2 = a1 * b1;
/ / c0 = a0 * b0;
/ / c1 = (a1 + a0) * (b1 + b0) - (c2 +, 0); / / c1ノ猭ボ (临⊿暗拜肈び
/ / c1 = (a1 + a0) (b1 + b0) - c2 c0 璶σ納眔び斌 癘眔э!
# include iostream
# include fstream
# define size 128
using namespace std;
/ / 璸衡计
int size _ of (char a [])
{
int i = 0;
while (a [i]! = \ 0) + +;
return;
}
class bignumber
{
private: / / 常そ秨ゑ耕糶 癘眔э糶 (?
/ /
public:
all sign;
int array [size + size]; / / 逆计氮秈皚
int length; / / 计
bignumber (); / / 穝计 0
void print (); / / 陪ボ计
void carry (); / / 秈干
bignumber operator = (int); / / 钡结
bignumber operator + (bignumber ); / / 更笲衡
bignumber operator - (bignumber ); / / 更笲衡
bignumber operator * (bignumber ); / / 更笲衡
int vbs (bignumber ); / / vs big or small ゑ计ぃタ璽腹)
};
/ / 0
bignumber:: bignumber ()
{
int i = 0;
while (i size + size) array [+ +] = 0;
length = 1;
sign = true; / / タ
}
/ / ゑ虫计ぃタ璽腹) a b = 1, a b = 0, a = b = 2
int bignumber: vbs (bignumber b)
{
if (length = = b.length)
{
int i = length 1;
while (array [i] = = b.array [in] i = 0) - -;
if ( 0) return 2; / / 单
else return (array [in] b.array [in])? 1: 0;
}
else return (length b.length)? 1: 0;
}
/ / 猭璸衡Ч常璶秈
void bignumber:: carry ()
{
int i = 0;
while (array [in] | | in length - 1)
{
if (array [in] 9)
{
array [i + 1] + = array [in] / 10;
array [i]% = 10;
}
else if (array [in] 0)
{
array [i] + = 10;
array [i + 1] = 1;
}
in + +;
}
in = size + (size 1); / / 璸衡ヘ玡计
while (array [] = = 0 i 0) - -;
length = i + 1;
}
void bignumber:: print ()
{
for (int j = length 1; j = 0; i --)
{
if (((j + 1)% 32 = = 0 | | j = = length - 1) length 30) cout final;
if (! sign j = = length - 1) cout -;
cout array [j];
}
cout
您可能关注的文档
- wcdma无线协议介绍)(Introduction of WCDMA wireless protocol).doc
- webservice中文件传输(File transfer in webservice).doc
- wget是一个十分常用命令行下载工具(WGet is a very common command line download tool).doc
- vc成员变量和static静态变量有什么区别(What is the difference between the VC member variable and the static static variable).doc
- vista系统c盘清理(vista系统c盘清理).doc
- win7瘦身减肥清理篇(Win7 weight loss clean-up articles).doc
- vi的各种尺寸(Various sizes of VI).doc
- win xp系统23招提速技巧(Win XP系统23招提速技巧).doc
- windows 7安装时有许多提示错误(There are a lot of tooltip errors when installing Windows 7).doc
- windows installer 服务无法启动(The Windows Installer service cannot start).doc
- 大学近代历史小论文(A small essay on modern history of University).doc
- 大汉光武九难之六技术之难(Nine to six Han Guangwu difficult technology).doc
- 大班幼儿习惯的培养(The cultivation of children's habits in large classes).doc
- 大理乡村旅游发展研究(Study on rural tourism development in Dali).doc
- 大理石干挂施工初步方案(Preliminary plan for construction of marble dry hanging).doc
- 大脑的思维程序(Brain thinking process).doc
- 大芯板名称真假难辨(The name of the core board is difficult to distinguish between genuine and false).doc
- 大荣法则(Daiei law).doc
- 大硬盘补丁相关问题(Big hard disk patch issues).doc
- 大豆脂肪测定方法研究(Study on determination method of soybean fat).doc
文档评论(0)