Solution of URI 1049::Animal
Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problem, you will inform me by comment.
#include <stdio.h>
#include <string.h>
int main()
{
char str[3][20];
int i;
for(i=0;i<3;i++)
{
scanf("%s",str[i]);
}
if(strcmp(str[0],"vertebrado")==0){
if(strcmp(str[1],"ave")==0){
if(strcmp(str[2],"carnivoro")==0)
printf("aguia\n");
else
printf("pomba\n");
}
else{
if(strcmp(str[2],"onivoro")==0)
printf("homem\n");
else
printf("vaca\n");
}
}
else{
if(strcmp(str[1],"inseto")==0
) {
if(strcmp(str[2],"hematofago")==0)
printf("pulga\n");
else
printf("lagarta\n");
}
else{
if(strcmp(str[2],"onivoro")==0)
printf("minhoca\n");
else
printf("sanguessuga\n");
}
}
return 0;
}
No comments