Dinner

Question: Dinner

Time Limit:  1 Sec   Memory Limit:  32 MB

Topic description

Little A is one member of ACM team. He had just won the gold in World Final. To celebrate, he decided to invite all to have one meal. As bowl, knife and other tableware is not enough in the kitchen, Little A goes to take backup tableware in warehouse. There are many boxes in warehouse, one box contains only one thing, and each box is marked by the name of things inside it. For example, if "basketball" is written on the box, which means the box contains only basketball. With these marks, Little A wants to find out the tableware easily. So, the problem for you is to help him, find out all the tableware from all boxes in the warehouse.

enter

There are many test cases. Each case contains one line, and one integer N at the first, N indicates that there are N boxes in the warehouse. Then N strings follow, each string is one name written on the box.

output

For each test of the input, output all the name of tableware.

sample input

3 basketball fork chopsticks
2 bowl letter

Sample output

fork chopsticks
bowl

hint

The tableware only contains: bowl, knife, fork and chopsticks.

Problem solving ideas

Water problem! There is nothing to say, just look for it.

#include <stdio.h>
#include <string.h>
char tab[4][15]={"bowl", "knife", "fork", "chopsticks"};
intmain()
{
    int n;
    char str[20];
    while (~scanf("%d%*c", &n))
    {
        while (n--)
        {
            scanf("%s", str);
            for (int i = 0; i < 4; i++)
            {
                if (!strcmp(str, tab[i]))
                    printf("%s ", str);
            }
        }
        puts("");
    }
    return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324852059&siteId=291194637