利用三目运算符:
#include <bits/stdc++.h>
using namespace std;
int main()
{
string a, b, c;
cin >> a >> b >> c;
if ( a == "vertebrado")
{
if( b == "ave")
( c == "carnivoro")? cout<<"aguia"<<endl : cout <<"pomba" << endl;
else
( c == "onivoro")? cout<< "homem" <<endl : cout << "vaca" << endl;
}
if ( a == "invertebrado")
{
if( b == "inseto")
( c == "herbivoro")? cout<<"lagarta"<<endl : cout <<"pulga" << endl;
else
( c == "onivoro")? cout<< "minhoca" <<endl : cout << "sanguessuga" << endl;
}
return 0;
}