Files
IT-Step/range_checker.cpp

38 lines
998 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <iostream>
using namespace std;
int main() {
int a;
int b;
int x;
cout << "Введiть нижню межу дiапазону: ";
cin >> a;
cout << "Введiть верхню межу дiапазону: ";
cin >> b;
if (a > b) {
int temp = a;
a = b;
b = temp;
cout << "Границi помiняно мiсцями. Дiапазон: [" << a << ", " << b << "]" << endl;
}
do {
cout << "Введiть число для перевiрки: ";
cin >> x;
if (x < a || x > b) {
cout << "Число " << x << " не потрапляє в дiапазон ["
<< a << ", " << b << "]" << endl;
}
} while (x < a || x > b);
cout << "Вiдмiнно! Число " << x << " потрапляє в дiапазон ["
<< a << ", " << b << "]" << endl;
return 0;
}