nvnnaidenov

Zad12

Sep 21st, 2021
484
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <math.h>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     double x;
  10.     double y;
  11.  
  12.     cout << "x = ";
  13.     cin >> x;
  14.     if(!cin)
  15.     {
  16.         cout << "Error, bad input!";
  17.         return 1;
  18.     }
  19.  
  20.     if(x >= 1)
  21.     {
  22.         y = log10(x) + 1.82;
  23.     }
  24.     else
  25.     {
  26.         y = x * x - 7 * x + 8.82;
  27.     }
  28.  
  29.     cout << setprecision(3) << setiosflags(ios::fixed);
  30.     cout << setw(10) << x << setw(10) << y << endl;
  31.  
  32.     return 0;
  33. }
RAW Paste Data