Advertisement
Leeen

ЯиМП №1 вар 7

Feb 13th, 2019
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3.  
  4. using namespace std;
  5.  
  6. double getX(double a, double b)
  7. {
  8.     if (a > b)
  9.         return 50 * (b / a) + b;
  10.     else if (a < b)
  11.         return (a - 5) / b;
  12.     else if (a == b)
  13.         return -100;
  14. }
  15.  
  16. int main()
  17. {
  18.     ifstream fileIn;
  19.     fileIn.open("FileIn.txt");
  20.     if (!fileIn.is_open())
  21.         cout << "Error, FileIn.txt is not found" << endl;
  22.     else
  23.     {
  24.         double a;
  25.         fileIn >> a;
  26.         double b;
  27.         fileIn >> b;
  28.         fileIn.close();
  29.  
  30.         double x = getX(a, b);
  31.         cout << "Result: " << x << endl;
  32.  
  33.         ofstream fileOut;
  34.         fileOut.open("FileOut.txt");
  35.         fileOut << x;
  36.         fileOut.close();
  37.     }
  38.    
  39.  
  40.     system("pause");
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement