-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrational.cc
66 lines (46 loc) · 1 KB
/
rational.cc
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
#include <iostream>
using namespace std;
class Rational{
long num_;
long den_;
public:
long get_numerator() const {
return num_;
}
long get_denominator() const{
return den_;
}
Rational& set_num(long num){
num = num_;
return *this;
}
Rational& set_den(long den){
den = den_;
return *this;
}
Rational& add(const Rational& r){
if(den_==r.get_denominator()){
num_+= r.get_numerator;
}
else if(den_!=r.get_denominator()){
//umnojavame znamenatelitel1 sus znamenatel2; umnojavame chislitel1 sus znam2 i chislitel2 sus znam1 i subirame chislitelite vrushtaiki stoinost razdelena na znamenatelq koito sega e raven;
}
return *this;
}
Rational& sub(const Rational& r){
if(den_ == r.get_denominator){
return *this;
}
Rational& operator +=(const Rational& r){
return *this;
}
Rational& operator -=(const Rational& r){
return *this;
}
};
int main() {
Rational r1(0,0);
r1.print();
(r.set_numerator(1)).set_denominator(2);
return 0;
}