-
Notifications
You must be signed in to change notification settings - Fork 0
/
BigInt.cpp
61 lines (53 loc) · 1018 Bytes
/
BigInt.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
// BigInt.cpp: îïðåäåëÿåò òî÷êó âõîäà äëÿ êîíñîëüíîãî ïðèëîæåíèÿ.
//
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include "BigClass.h"
#pragma warning(disable : 4996)
int main(int argc, const char * argv[])
{
BigIntClass a;
BigIntClass b;
BigIntClass Res;
if (argc>5 && (!strcmp(argv[5], "-b")))
{
a.ReadBinFile(argv[1]);
b.ReadBinFile(argv[3]);
}
else
{
a.ReadTextFile(argv[1]);
b.ReadTextFile(argv[3]);
}
if (argv[2][0] == '+')
Res = a + b;
if (argv[2][0] == '-')
Res = a - b;
if (argv[2][0] == '*')
Res = a * b;
if (argv[2][0] == '/')
Res = a / b;
if (argv[2][0] == '%')
Res = a % b;
if (argv[2][0] == '^')
{
BigIntClass c;
if (!strcmp(argv[5], "-b"))
c.ReadBinFile(argv[6]);
else
c.ReadTextFile(argv[5]);
Res = degree(a, b, c);
c.Clear();
}
if (argc>5 && (!strcmp(argv[5], "-b")))
Res.WriteBinFile(argv[4]);
else
Res.WriteTextFile(argv[4]);
a.Clear();
b.Clear();
Res.Clear();
return 0;
}