Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int number;
- cin >> number;
- if (number < 100) {
- cout << "Less than 100" << endl;;
- }
- else if (number <= 200) {
- cout << "Between 100 and 200" << endl;;
- }
- else {
- cout << "Greater than 200" << endl;
- }
- return 0;
- }
- Решение с тернарен оператор:
- #include <iostream>
- using namespace std;
- int main() {
- int number;
- cin >> number;
- cout << (number < 100 ? "Less than 100" : number <= 200 ? "Between 100 and 200" : "Greater than 200") << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement