spacerose

5 задача практика

Mar 11th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. using namespace std;
  2. int main()
  3. {
  4.     double a,k=2.0;
  5.     int n = 0;
  6.     cin >> a;
  7.     if ((a <= 1.0) || (a > 1.5)) cout << "error";
  8.     else
  9.     {
  10.         if (a <= 1.50) n++;
  11.         if (a <= 1.33) n++;
  12.         if (a <= 1.25) n++;
  13.         if (a <= 1.20) n++;
  14.         while (n >= 0 && (1.0+1.0/k)>=a) {
  15.             printf("%.2f", 1.0 + 1.0 / k);
  16.             cout << " ";
  17.             k++;
  18.             n--;
  19.         }
  20.     }
  21. }
Add Comment
Please, Sign In to add comment