KeiroKamioka

Jigoku1

Jan 27th, 2021
777
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include <iostream>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. struct fraction
  10. {
  11. public:
  12.     int a;
  13.     int b;
  14.  
  15.     fraction(int _a, int _b)
  16.     {
  17.         a = _a;
  18.         b = _b;
  19.     }
  20.  
  21.     string to_string()
  22.     {
  23.         return "(" + std::to_string(a) + "/" + std::to_string(b) + ")";
  24.     }
  25.  
  26.     //This function subtracts the input fraction from this fraction
  27.     //Do not simplify the result in any way
  28.     fraction subtract(fraction f)
  29.     {
  30.         // Your code starts here
  31.         fraction subFrac;
  32.         cout << "Enter your Numerator";
  33.         cin >> subFrac.a;
  34.         cout << "Enter your Denominator";
  35.         cin >> subFrac.b;
  36.  
  37.         return = ((f.a * subFrac.b) - (f.b * subFrac.a)) / (f.b * subFrac.b);
  38.  
  39.         // Your code ends here
  40.     }
  41.  
  42.     //This function divides this fraction by the input fraction
  43.     //Do not simplify the result in any way
  44.     fraction divide(fraction f)
  45.     {
  46.         // Your code starts here
  47.         fraction divFrac;
  48.         cout << "Enter your Numerator";
  49.         cin >> divFrac.a;
  50.         cout << "Enter your Denominator";
  51.         cin >> divFrac.b;
  52.  
  53.         return = ((f.a * divFrac.b) - (f.b * divFrac.a)) / (f.b * divFrac.b);
  54.  
  55.         // Your code ends here
  56.     }
  57.  
  58.     //This function simplifies the fraction
  59.     //Definition of simplification: https://www.mathsisfun.com/simplifying-fractions.html
  60.     fraction simplify()
  61.     {
  62.  
  63.         // Your code ends here
  64.     }
  65. };
  66. //After
  67.  
  68. fraction main() {
  69.  
  70.     fraction f1;
  71.  
  72.     cout << "Enter your Numerator";
  73.     cin >> f1.a;
  74.     cout << "Enter your Denominator";
  75.     cin >> f1.b;
  76.     cout << subtract(f1);
  77.    
  78. }
RAW Paste Data