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
#include<iostream>
using namespace std;
class fraction{
private:
long long int a,b;
public:
friend ostream &operator<<(ostream &potok , const fraction &f);
friend istream &operator>>(istream &potok , fraction &f);
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(b * other.a + a * other.b, b * other.b);
}
};
ostream &operator<<(ostream &potok , const fraction &f){
potok << f.a << "/" << f.b << endl;
return potok ;
}
istream &operator>>(istream &potok , fraction &f){
potok >> f.a >> f.b;
return potok ;
}
int main(){
fraction x,y;
cin >> x >> y;
cout << (x + y);
return 0;
}