用String设置的大数及部分算法(java),大数的农夫算法、分治算法等都可以用到(String set with the large number and part of the algorithm (Java), large number of farmers algorithm, divide and conquer algorithm, etc. can be used).doc
- 1、本文档共21页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
用String设置的大数及部分算法(java),大数的农夫算法、分治算法等都可以用到(String set with the large number and part of the algorithm (Java), large number of farmers algorithm, divide and conquer algorithm, etc. can be used)
用String设置的大数及部分算法(java),大数的农夫算法、分治算法等都可以用到(String set with the large number and part of the algorithm (Java), large number of farmers algorithm, divide and conquer algorithm, etc. can be used)
Using String and int[] to achieve a large integer algorithm
The integration of large integer addition, subtraction (only, multiplication, larger than the subtrahend minuend) multiplied by 2, divided by 2, minus 1, and determine whether the 1 parity judgment method, and toString (show) method with toString (method), 0, 1, 10.
Multiplication and addition, after many tests and modifications, basically do not have any problems, division, because it did not use, so did not write.
Can be used in large numbers algorithm, farmer algorithm, brute force algorithm, and so on.
Public, class, MyBigInt {
Public, static, final, int[], ten = {10};
Public, static, final, int[], zero = {0};
Public, static, final, int[], one = {1};
Int[] myInt;
Public, int[], getMyInt () {
Return myInt;
}
Public, void, setMyInt (int[], myInt) {
This.myInt = myInt;
}
Public, MyBigInt () {
MyInt = zero;
}
Public MyBigInt (String, a) {
MyInt = new, int[a.length ()];
For (int i = 0; I myInt.length; i++) {
MyInt[i] = Integer.parseInt (String.valueOf (a.charAt (myInt.length)
- I - 1));
}
}
Public, MyBigInt, chengFa (MyBigInt, myBigInt) {
Int[] myIntA = myInt;
Int[] myIntB = myBigInt.getMyInt ();
Int, a, b;
Int s = 0;
Int c = 0;
Int[], TMP, result;
TMP = new, int[myIntA.length + myIntB.length];
Result = new, int[myIntA.length + myIntB.length];
For (int i = 0; I myIntA.length; i++) {
For (int j = 0; J myIntB.length; j++) {
A = myIntA[i];
B = myIntB[j];
S = (a * B);
Tmp[i + j] = s;
}
}
For (int, I = 0, I, tmp.length - 1, i++) {
C = tmp[i] / 10;
Tmp[i] = tmp[i]% 10;
Tmp[i + 1] = tmp[i + 1] + c;
}
For (int i = 0; I tmp.length; i++) {
Result[i] = tmp[i];
}
While (result[result.length - 1] = = 0) {
TMP = new, int[result.length - 1];
For (int i = 0; I tmp.length; i++) {
Tmp[i] = result[i];
}
Result = tmp;
}
MyBigInt, r
您可能关注的文档
- 学习室内设计必看的AutoCAD教程【精校版】(Learning interior design must see the AutoCAD tutorial [refined school version]).doc
- 学习动机、学习迁移与学习策略(Learning motivation, learning transfer and learning strategies).doc
- 学习小组文化墙设计(Learning group cultural wall design).doc
- 学习十七届三中全会精神入党思想汇报(Learn the spirit of the third Plenary Session of the 17th CPC Central Committee and report to the party).doc
- 学习散文(Study prose).doc
- 学习编程(Learning programming).doc
- 学习网球的心得体会(The experience of learning tennis).doc
- 学习autocad的心得(Learn AutoCAD's experience).doc
- 学习英语兴趣1(Interest in learning English 1).doc
- 学习跑酷需要锻炼的一些内容(Learning Parkour requires some exercise).doc
文档评论(0)