Problem :
Animal
By Neilor Tonin, URI Brazil
Timelimit: 1
In this problem, your job is to read three Portuguese words. These words define an animal according to the table below, from left to right. After, print the chosen animal defined by these three words.
Input
The input contains 3 words, one by line, that will be used to identify the animal, according to the above table, with all letters in lowercase.
Output
Print the animal name according to the given input.
Sample Inputs | Sample Outputs |
vertebrado mamifero onivoro | homem |
vertebrado ave carnivoro | aguia |
invertebrado anelideo onivoro | minhoca |
Solution:
#include<stdio.h>
#include<string.h>
int
main()
{
char
s[100] , a[100], b[100];
gets
(s);
gets
(a);
gets
(b);
if
(
strcmp
(s,
"vertebrado"
)==0){
if
(
strcmp
(a,
"ave"
)==0){
if
(
strcmp
(b,
"carnivoro"
)==0)
printf
(
"aguia\n"
);
else
if
(
strcmp
(b,
"onivoro"
)==0)
printf
(
"pomba\n"
);
}
else
if
(
strcmp
(a,
"mamifero"
)==0){
if
(
strcmp
(b,
"onivoro"
)==0)
printf
(
"homem\n"
);
else
if
(
strcmp
(b,
"herbivoro"
)==0)
printf
(
"vaca\n"
);
}
}
else
if
(
strcmp
(s,
"invertebrado"
)==0){
if
(
strcmp
(a,
"inseto"
)==0){
if
(
strcmp
(b,
"herbivoro"
)==0)
printf
(
"lagarta\n"
);
else
if
(
strcmp
(b,
"hematofago"
)==0)
printf
(
"pulga\n"
);
}
else
if
(
strcmp
(a,
"anelideo"
)==0){
if
(
strcmp
(b,
"onivoro"
)==0)
printf
(
"minhoca\n"
);
else
if
(
strcmp
(b,
"hematofago"
)==0)
printf
(
"sanguessuga\n"
);
}
}
return
0;
}
No comments:
Post a Comment