@@ -17,8 +17,8 @@ HugeInt::HugeInt(int d) {
1717 negative = false ;
1818}
1919
20- HugeInt::HugeInt (int num[41 ], int dep) {
21- for (int i = 0 ; i < 41 ; i++) {
20+ HugeInt::HugeInt (int num[40 ], int dep) {
21+ for (int i = 0 ; i < 40 ; i++) {
2222 number[i] = num[i];
2323 }
2424 depth = dep;
@@ -43,7 +43,13 @@ void HugeInt::set(string str) {
4343 }
4444}
4545
46- string HugeInt::get () {
46+ void HugeInt::set (int num[40 ]) {
47+ for (int i = 0 ; i < 40 ; i++) {
48+ number[i] = num[i];
49+ }
50+ }
51+
52+ string HugeInt::get () const {
4753 string str;
4854 if (negative) {
4955 str += ' -' ;
@@ -58,14 +64,40 @@ string HugeInt::get() {
5864 return str;
5965}
6066
61- bool HugeInt::check_zero () {
67+ bool HugeInt::check_zero () const {
6268 for (int i = 0 ; i < depth; i++) {
6369 if (number[i]) return false ;
6470 }
6571 return true ;
6672}
6773
68- int HugeInt::compare (HugeInt &b) {
74+ void HugeInt::set_minus (bool state) {
75+ negative = state;
76+ }
77+
78+ bool HugeInt::has_minus () const {
79+ return negative;
80+ }
81+
82+ int HugeInt::get_depth () const {
83+ return depth;
84+ }
85+
86+ void HugeInt::set_depth (int dep) {
87+ depth = dep;
88+ }
89+
90+ void HugeInt::set_digit (int index, int digit) {
91+ number[index] = digit;
92+ }
93+
94+ int HugeInt::get_digit (int index) const {
95+ return number[index];
96+ }
97+
98+
99+
100+ int HugeInt::compare (HugeInt &b) const {
69101 if (negative && !b.negative ) {
70102 return -1 ;
71103 } else if (!negative && b.negative ) {
@@ -216,4 +248,12 @@ HugeInt HugeInt::dif(HugeInt &b) {
216248 } else if (!negative && b.negative ) {
217249 return this ->simple_sum (b);
218250 }
251+ }
252+
253+ // операторы
254+
255+ HugeInt HugeInt::operator -() const {
256+ HugeInt temp (*this );
257+ temp.negative = !temp.negative ;
258+ return temp;
219259}
0 commit comments