-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHugeInteger_main_Ch_10.cpp
More file actions
75 lines (54 loc) · 1.75 KB
/
HugeInteger_main_Ch_10.cpp
File metadata and controls
75 lines (54 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// 12191706 ±èÁ¤Áø
// HugeInteger test program.
#include <iostream>
#include "HugeInteger_Ch_10.h"
using namespace std;
int main() {
HugeInteger n1{ 7654321 };
HugeInteger n2{ 7891234 };
HugeInteger n3{ "99999999999999999999999999999" };
HugeInteger n4{ "1" };
HugeInteger n5;
HugeInteger n6;
HugeInteger n7;
cout << "n1 is " << n1 << "\nn2 is " << n2
<< "\nn3 is " << n3 << "\nn4 is " << n4
<< "\nn5 is " << n5 << "\n\n";
n5 = n1 + n2;
cout << n1 << " + " << n2 << " = " << n5 << "\n\n";
cout << n3 << " + " << n4 << "\n=" << (n3 + n4) << "\n\n";
n5 = n1 + 9;
cout << n1 << " + " << 9 << " = " << n5 << "\n\n";
n5 = n2 + "10000";
cout << n2 << " + " << "10000" << " = " << n5 << "\n\n";
// HugeInteger n6 is for test multipication operation
n6 = n1 * n2;
cout << n1 << " * " << n2 << " = " << n6 << "\n\n";
cout << n3 << " * " << n4 << " = " << (n3 * n4) << "\n\n";
n6 = n1 * 9;
cout << n1 << " * " << 9 << " = " << n6 << "\n\n";
n6 = n2 * "10000";
cout << n2 << " * " << "10000" << " = " << n6 << "\n\n";
// HugeInteger n7 is for test division operation
n6 = n1 / n2;
cout << n1 << " / " << n2 << " = " << n6 << "\n\n";
cout << n3 << " / " << n4 << " = " << (n3 / n4) << "\n\n";
n6 = n1 / 9;
cout << n1 << " / " << 9 << " = " << n6 << "\n\n";
n6 = n2 / "10000";
cout << n2 << " / " << "10000" << " = " << n6 << "\n\n";
// test relational and equality operators.
cout << "Display equality and relation of n1 and n2.\n";
if (n1 == n2)
cout << n1 << " == " << n2 << "\n";
if (n1 != n2)
cout << n1 << " != " << n2 << "\n";
if (n1 > n2)
cout << n1 << " > " << n2 << "\n";
if (n1 < n2)
cout << n1 << " < " << n2 << "\n";
if (n1 >= n2)
cout << n1 << " >= " << n2 << "\n";
if (n1 <= n2)
cout << n1 << " <= " << n2 << "\n";
}