Advertisement
LisunovaMaryna

lab1.1 c++

Sep 25th, 2023 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int radius, side = 0;
  8.     cout << "The program will determine whether the circle fits into the square.\n";
  9.     bool IsCorrect;
  10.     cout << "Enter radius: ";
  11.     do
  12.     {
  13.         IsCorrect = false;
  14.         cin >> radius;
  15.         if ((cin.fail()) or (radius < 0) or (radius == 0))
  16.         {
  17.             IsCorrect = true;
  18.             cout << "Incorrect value. Enter the number: ";
  19.         }
  20.         cin.clear();
  21.         while (cin.get() != '\n');
  22.     } while (IsCorrect);
  23.     cout << "Enter side: ";
  24.     do
  25.     {
  26.         IsCorrect = false;
  27.         cin >> side;
  28.         if ((cin.fail()) or (side < 0) or (side == 0))
  29.         {
  30.             IsCorrect = true;
  31.             cout << "Incorrect value. Enter the number: ";
  32.         }
  33.         cin.clear();
  34.         while (cin.get() != '\n');
  35.     } while (IsCorrect);
  36.     if (radius * 2 < side)
  37.     {
  38.         cout << "Fit in.\n" << endl;
  39.     }
  40.     else
  41.     {
  42.         cout << "Not fit in.\n" << endl;
  43.     }
  44.     return 0;
  45. }
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement