include iostream using namespace std class fraction private long long

 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
#include<iostream>
using namespace std;
class fraction{
private:
long long int a, b;
public:
fraction(long long int a = 0, long long int b = 1)
{
this->a = a;
this->b = b;
}
void show()
{
cout << a << '/' << b;
}
void read()
{
char c;
cin >> a >> c >> b;
}
bool operator <(fraction other){
if (a * other.b < b * other.a && b * other.a > a * other.b){
return true;
}
else{
return false;
}
}
bool operator >(fraction other){
if (a * other.b > b * other.a && b * other.a < a * other.b){
return true;
}
else{
return false;
}
}
bool operator =(fraction other){
if (a * other.b == b * other.a && b * other.a == a * other.b){
return true;
}
else{
return false;
}
}
fraction operator +(int z){
return fraction(b * z + a, b * 1);
}
fraction operator/(fraction other){
return fraction(a * other.b, b * other.a);
}
friend fraction operator-(int z, fraction d);
};
fraction operator-(int z, fraction d){
//cout << d.a << " " << d.b << endl;
return fraction((z * d.b) - d.a, d.b);
}
int main(){
fraction x;
int z;
cin >> z;
x.read();
(z- x).show();
system("pause");
return 0;
}