1 条题解

  • 0
    @ 2024-12-18 14:07:30

    C :

    #include<stdio.h>
    #include<string.h>
    
    int main()
    {
    	char w1[20],w2[20],w3[20];
    	scanf("%s\n%s\n%s",w1,w2,w3);
    
    	if (strcmp(w1,"vertebrado")==0)
    	{
    	    if (strcmp(w2,"ave")==0)
    		{
    		    if (strcmp(w3,"carnivoro")==0)
    			{
    			    printf("aguia");
    			}
    			else if (strcmp(w3,"onivoro")==0)
    			{
    			    printf("pomba");
    			}
    		}
    		else if (strcmp(w2,"mamifero")==0)
    		{
    		    if (strcmp(w3,"onivoro")==0)
    			{
    			    printf("homem");
    			}
    			else if (strcmp(w3,"herbivoro")==0)
    			{
    			    printf("vaca");
    			}
    		}
    	}
    	if (strcmp(w1,"invertebrado")==0)
    	{
    	    if (strcmp(w2,"inseto")==0)
    		{
    		    if (strcmp(w3,"hematofago")==0)
    			{
    			    printf("pulga");
    			}
    			else if (strcmp(w3,"herbivoro")==0)
    			{
    			    printf("lagarta");
    			}
    		}
    		else if (strcmp(w2,"anelideo")==0)
    		{
    		    if (strcmp(w3,"hematofago")==0)
    			{
    			    printf("sanguessuga");
    			}
    			else if (strcmp(w3,"onivoro")==0)
    			{
    			    printf("minhoca");
    			}
    		}
    	}
    	
    
        return 0;
    }
    

    C++ :

    #include<stdio.h>
    int main()
    {
    	char n1[13],n2[13],n3[13];
    	scanf("%s%s%s",n1,n2,n3);
    	char ch1=n1[0],ch2=n2[0],ch3=n3[0],ch4=n3[2];
    	if(ch1=='v')
    	{
    		if(ch2=='a')
    		{
    			if(ch3=='c')
    			{
    				printf("aguia");
    			} 
    			else if(ch3=='o')
    			{
    				printf("pomba"); 
    			}
    		}
    		else if(ch2=='m')
    		{
    			if(ch3=='o')
    			{
    				printf("homem");
    			} 
    			else if(ch3=='h')
    			{
    				printf("vaca");
    			}
    			
    		}
    	}
    	else if(ch1=='i')
    	{
    		if(ch2=='i')
    		{
    			if(ch4=='m')
    			printf("pulga");
    			else if(ch4=='r')
    			printf("lagarta");
    		}
    		else if(ch2=='a')
    		{
    			if(ch3=='h')
    			printf("sanguessuga");
    			else if(ch3=='o')
    			printf("minhoca"); 
    		}
    	}
    	return 0;
    }
    

    Java :

    import java.util.Scanner;
    
    public class Main {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            String one = scanner.next();
            String two = scanner.next();
            String three = scanner.next();
    if (one.equals("vertebrado")){
    
        if (two.equals("ave")) {
            if (three.equals("carnivoro")) {
                System.out.println("aguia");
            }else if (three.equals("onivoro")) {
                System.out.println("pomba");
            }
    
        }else if (two.equals("mamifero")) {
            if (three.equals("onivoro")) {
                System.out.println("homem");
            }else if (three.equals("herbivoro")) {
                System.out.println("vaca");
            }
    
        }
    }else if (one.equals("invertebrado")) {
        if (two.equals("inseto")) {
            if (three.equals("hematofago")) {
                System.out.println("pulga");
            }else if (three.equals("herbivoro")) {
                System.out.println("lagarta");
            }
        }else if (two.equals("anelideo")){
            if (three.equals("hematofago")) {
                System.out.println("sanguessuga");
            }else if (three.equals("onivoro")) {
                System.out.println("minhoca");
            }
    
        }
    }
        }
    }
    
    • 1

    信息

    ID
    658
    时间
    1000ms
    内存
    128MiB
    难度
    5
    标签
    提交数
    67
    已通过
    26
    上传者