URI-1049 Solve

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.
Input SamplesOutput Samples
vertebrado
mamifero
onivoro
homem
vertebrado
ave
carnivoro
aguia
invertebrado
anelideo
onivoro
minhoca
Problem link [URI 1049##link##]

Solution

  • [tab]
    • C
      • #include <stdio.h>
        #include <string.h>
        int main()
        {
            char c1[]="vertebrado", c11[22]="ave", c12[]="mamifero";
            char c111[]="carnivoro", c112[]="onivoro", c124[]="herbivoro";
            char a1[]="aguia", a2[]="pomba", a3[]="homem", a4[]="vaca";
            char c2[]="invertebrado", c21[]="inseto", c22[]="anelideo";
            char c211[]="hematofago", a5[]="pulga", a6[]="lagarta";
            char a7[]="sanguessuga", a8[]="minhoca";
            char a[22], b[22], c[22];
            scanf("%s", a);
            if(0==strcmp(a,c1))
            {
                scanf("%s",b);
                if(0==strcmp(b,c11))
                {
                    scanf("%s",c);
                    if(0==strcmp(c,c111))
                        printf("%s\n",a1);
                    else if(0==strcmp(c,c112))
                        printf("%s\n",a2);
                }
                if(0==strcmp(b,c12))
                {
                    scanf("%s",&c);
                    if(0==strcmp(c,c112))
                        printf("%s\n",a3);
                    else if(0==strcmp(c,c124))
                        printf("%s\n",a4);
                }
            }
            else if(0==strcmp(a,c2))
            {
                scanf("%s",b);
                if(0==strcmp(b,c21))
                {
                    scanf("%s",&c);
                    if(0==strcmp(c,c211))
                        printf("%s\n",a5);
                    else if(0==strcmp(c,c124))
                        printf("%s\n",a6);
                }
                if(0==strcmp(b,c22))
                {
                    scanf("%s",&c);
                    if(0==strcmp(c,c211))
                        printf("%s\n",a7);
                    else if(0==strcmp(c,c112))
                        printf("%s\n",a8);
                }
            }
            return 0;
        }
    • C++
      • #include <iostream>
        #include <cstring>
        
        using namespace std;
        
        int main()
        {
         string c;
        
         cin >> c;
        
         if(c == "vertebrado"){
          
          cin >> c;
          if(c == "ave"){
        
           cin >> c;
           if(c == "carnivoro"){
            cout << "aguia" << endl;
           }else{
            cout << "pomba" << endl;
           }
          }else{
        
           cin >> c;
           if(c == "onivoro"){
            cout << "homem" << endl;
           }else{
            cout << "vaca" << endl;
           }
          }
         }else{
        
          cin >> c;
          if(c == "inseto"){
        
           cin >> c;
           if(c == "hematofago"){
            cout << "pulga" << endl;
           }else{
            cout << "lagarta" << endl;
           }
          }else{
        
           cin >> c;
           if(c == "hematofago"){
            cout << "sanguessuga" << endl; 
           }else{
            cout << "minhoca" << endl;
           }
          }
         }
         return 0;
        }
3/Technology/post-list
Name

Codeforces,53,Problem Solve,90,Programming Tricks,1,URI,37,
ltr
item
DorHubs: URI-1049 Solve
URI-1049 Solve
https://resources.urionlinejudge.com.br/gallery/images/problems/UOJ_1049_b.png
DorHubs
https://dorhubs.blogspot.com/2019/09/uri-1049-solve.html
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/2019/09/uri-1049-solve.html
true
9087637800571592252
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy