forked from zDonik1/PowerTower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
83 lines (71 loc) · 1.83 KB
/
Main.cpp
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
76
77
78
79
80
81
82
83
#include "SuperLong.h"
#include <iostream>
#include <string>
int main()
{
// test adding
{
SuperLong a(125);
SuperLong b(2590);
SuperLong c;
c.Add(a, b);
std::cout << c.ToString() << std::endl;
system("pause");
}
// test multiply
{
SuperLong a(1212359);
SuperLong b(2566);
SuperLong c;
c.Multiply(a, b);
std::cout << c.ToString() << std::endl;
a.FromInt(2);
b.FromInt(2);
a.Multiply(b, a);
std::cout << a.ToString() << std::endl;
system("pause");
}
// test power
{
SuperLong a(2);
SuperLong b(3);
SuperLong c;
c.Power(a, b);
std::cout << c.ToString() << std::endl;
system("pause");
}
// test half
{
SuperLong a(145);
a.half();
std::cout << a.ToString() << std::endl;
system("pause");
}
SuperLong answer;
std::vector<int> powers; //For saving the powers entered
char enteredCharacter;
int integer;
//Prompting the user for power numbers
std::cout << "Enter all numbers for the power-tower (finish by entering a !)" << std::endl;
//Entering and emplacing all the numbers into a vector object
while (true) {
std::cin >> enteredCharacter;
if (enteredCharacter == '!') {
break;
}
integer = enteredCharacter - 48; //Converting character to integer
powers.emplace_back(integer);
}
//Calculate the power of another power :)
answer.Save(powers.back());
for (auto itr = powers.rbegin(); itr != powers.rend(); ++itr) {
answer.Power(IntToSL(*itr), answer);
std::cout << "Debug: answer.ToString() = " << answer.ToString() << std::endl;
}
//Output the final value
std::string outputString = answer.ToString();
std::cout << outputString << std::endl;
//End of program
system("pause");
return 0;
}