Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- string country;
- getline(cin, country);
- string language;
- if (country == "England" || country == "USA") {
- language = "English";
- }
- else if (country == "Spain" || country == "Argentina" || country == "Mexico") {
- language = "Spanish";
- }
- else {
- language = "unknown";
- }
- cout << language << endl;
- return 0;
- }
- Решение с тернарен оператор:
- #include <iostream>
- using namespace std;
- int main() {
- string country;
- getline(cin, country);
- string language =
- country == "England" || country == "USA" ? "English" :
- country == "Spain" || country == "Argentina" || country == "Mexico" ? "Spanish" : "unknown";
- cout << language << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement