-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2018_March_03_Task1
79 lines (61 loc) · 1.18 KB
/
2018_March_03_Task1
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
#include <iostream>
#include <cmath>
using namespace std;
struct irrational{
public:
int rat;
int irr;
void irrational(int r, int i){
rat = r;
irr = i;
}
void operator=(irrational B){
rat = B.rat;
irr = B.irr;
if(fmod(sqrt(irr), 1) == 0){
rat+=sqrt(irr);
irr = 0;
}
}
};
struct chain{
public:
chain *head = NULL;
chain *link = NULL;
chain *next = NULL;
irrational value = NULL;
void chain(chain *h, chain *li, irrational v){
head = h;
link = li;
link->next = this;
value = v;
next = NULL;
}
void operator= (chain B){
value = B.value;
}
~chain(){
delete[]head;
delete[]next;
delete[]link;
delete value;
}
chain* front(){
for(chain *i = this; 1; i = i->next){
if(i->next == NULL) return i;
}
}
bool empty(){
return head!=NULL;
}
void push(irrational a){
chain z(head, front(), a);
}
void pop(){
delete front();
front()->link = NULL;
}
};
int main() {
return 0;
}