ガイドラインは次のために呼び出します。intの配列で50桁の整数を表す方法は?
BigIntegers will be represented with 50 digit arrays of int (where each integer in the array is an integer in the range 0..9).
You will have a class called BigInteger that has the following methods:
BigInteger() --- initialize the BigInteger to 0
BigInteger(int n) --- initialize the BigInteger to the value of n
BigInteger(BigInteger n) --- a copy constructor
私の質問があり、これについて行くの最も効果的な方法は何ですか?が、唯一の0に配列を初期化するために動作するようです
public class BigInteger {
int[] BigInteger = new int[50];
public BigInteger() {
for(int i = 0; i < BigInteger.length; i++) {
BigInteger[i] = 0;
}
}
が....私はスタックオーバーフローを中心にチェックしましたが、空まで来ています:現在、私は持っています。誰かがこれについてどうやって正しい方向に向けるのだろうか?
1.フィールドがBigIntegerとも呼ばれていない場合は、おそらくもっと簡単でしょう。 2.あなたが直面している問題はどこですか? 「効果的」とはどういう意味ですか?おそらく、10で割って、2番目のコンストラクタで整数が0になるまで連続した配列エントリのモジュールを取り出し、3番目のコンストラクタに配列をコピーするだけです。 –
コードは分かりませんが、コードを明確にするために、クラスと属性に同じ名前を再利用しない方が良いでしょう。コードを読んだら後で誤解することがあります。すぐにわからないでしょう – azro
ゼロ'int []'を出してください。数値配列はデフォルトでゼロに初期化されます。 – Andreas