Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Fraction {
- long long x, y;
- public:
- Fraction(long long x = 0, long long y = 1);
- void show();
- Fraction operator -() {
- long long a, c, z;
- a = this -> x * (-1);
- c = this -> y;
- return Fraction(a, c);
- }
- Fraction operator + (long long b) {
- long long a, c;
- a = this -> x + b * this -> y;
- c = this -> y;
- return Fraction(a, c);
- }
- void read();
- };
- Fraction::Fraction(long long x, long long y) {
- this -> x = x;
- this -> y = y;
- }
- void Fraction::show(){
- cout << x << "/" << y;
- }
- void Fraction::read() {
- char ch;
- cin >> x >> ch >> y;
- }
- int main() {
- long long z;
- Fraction a, c;
- cin >> z;
- a.read();
- a = -a;
- c = a + z;
- c.show();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement