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
#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;
}
fraction operator*(fraction other){
return fraction(a * other.a, b * other.b);
}
fraction operator+(fraction other){
return fraction(b * other.a + a * other.b, b * other.b);
}
fraction operator-(fraction other){
return fraction(a * other.b - b * other.a, b * other.b);
}
fraction operator/(fraction other){
return fraction(a * other.b, b * other.a);
}
};
int main(){
fraction x,y;
x.read();
y.read();
(x / y).show();
}