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