AcWing 670. 动物 ---- C++ 多if 组合
原题链接
简单
作者:
cheng2099
,
2021-01-10 22:12:04
,
所有人可见
,
阅读 900
#include <iostream>
#include <string>
using namespace std;
int main() {
string str1, str2, str3;
cin >> str1 >> str2 >> str3;
if (str1 == "vertebrado") {
if (str2 == "ave") {
if (str3 == "carnivoro") {
printf("aguia\n");
} else if (str3 == "onivoro") {
printf("pomba\n");
}
} else if (str2 == "mamifero") {
if (str3 == "onivoro") {
printf("homem\n");
} else if (str3 == "herbivoro") {
printf("vaca\n");
}
}
} else if(str1 == "invertebrado") {
if (str2 == "inseto") {
if (str3 == "hematofago") {
printf("pulga\n");
} else if (str3 == "herbivoro") {
printf("lagarta\n");
}
} else if (str2 == "anelideo") {
if (str3 == "hematofago") {
printf("sanguessuga\n");
} else if (str3 == "onivoro") {
printf("minhoca\n");
}
}
}
return 0;
}