Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- string dayOfWeek;
- cin >> dayOfWeek;
- int price = 0;
- if (dayOfWeek == "Monday" || dayOfWeek == "Tuesday" || dayOfWeek == "Friday") {
- price = 12;
- }
- else if (dayOfWeek == "Wednesday" || dayOfWeek == "Thursday") {
- price = 14;
- }
- else {
- price = 16;
- }
- cout << price << endl;
- return 0;
- }
- Решение с тернарен оператор:
- #include <iostream>
- using namespace std;
- int main() {
- string dayOfWeek;
- cin >> dayOfWeek;
- int price =
- dayOfWeek == "Saturday" || dayOfWeek == "Sunday" ? 16 :
- dayOfWeek == "Wednesday" || dayOfWeek == "Thursday" ? 14 : 12;
- cout << price << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement