Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Fraction {
  6. long long x, y;
  7. public:
  8. Fraction(long long x = 0, long long y = 1);
  9. void show();
  10. Fraction operator -() {
  11. long long a, c, z;
  12. a = this -> x * (-1);
  13. c = this -> y;
  14. return Fraction(a, c);
  15. }
  16. Fraction operator + (long long b) {
  17. long long a, c;
  18. a = this -> x + b * this -> y;
  19. c = this -> y;
  20. return Fraction(a, c);
  21. }
  22. void read();
  23. };
  24.  
  25. Fraction::Fraction(long long x, long long y) {
  26. this -> x = x;
  27. this -> y = y;
  28. }
  29.  
  30. void Fraction::show(){
  31. cout << x << "/" << y;
  32. }
  33.  
  34. void Fraction::read() {
  35. char ch;
  36. cin >> x >> ch >> y;
  37. }
  38.  
  39. int main() {
  40. long long z;
  41. Fraction a, c;
  42. cin >> z;
  43. a.read();
  44. a = -a;
  45. c = a + z;
  46. c.show();
  47. system("pause");
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement