Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int hour;
- cin >> hour;
- string dayOfWeek;
- cin >> dayOfWeek;
- if (dayOfWeek != "Sunday" && hour >= 10 && hour <= 18) {
- cout << "open" << endl;
- }
- else {
- cout << "closed" << endl;
- }
- return 0;
- }
- Решение с тернарен оператор:
- #include <iostream>
- using namespace std;
- int main() {
- int hour;
- cin >> hour;
- string dayOfWeek;
- cin >> dayOfWeek;
- cout << (dayOfWeek != "Sunday" && hour >= 10 && hour <= 18 ? "open" : "closed") << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement