nbut [1217] Dinner

来源:互联网 发布:网络逃犯查询 编辑:程序博客网 时间:2024/05/23 10:48
  • [1217] Dinner

  • 时间限制: 1000 ms 内存限制: 32768 K
  • 问题描述
  • 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.
  • 输入
  • 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.
  • 输出
  • For each test of the input, output all the name of tableware.
  • 样例输入
  • 3 basketball fork chopsticks2 bowl letter
  • 样例输出
  • fork chopsticksbowl
  • 提示
  • The tableware only contains: bowl, knife, fork and chopsticks.
  • 来源
  • 辽宁省赛2010
  • 操作

 

#include<iostream>#include<cstdio>#include<cstring>char s[10000][15];int main(){    int  i,j,k,n;    char a[15];    while(scanf("%d",&n)!=EOF)    {         int t=0;         int a1=1,a2=1,a3=1,a4=1;         char s1[12]="chopsticks";         for(i=0;i<n;i++)        {            scanf("%s",&a);           if((strcmp(a,"fork")==0)&&a1)           {               //printf("fdshjk");               //strcpy("fork",s[t]);              //               s[t][0]='f';               s[t][1]='o';               s[t][2]='r';               s[t][3]='k';               s[t][4]='\0';               t++;               a1=0;           }           else            if((strcmp(a,"knife")==0)&&a2)            {               s[t][0]='k';               s[t][1]='n';               s[t][2]='i';               s[t][3]='f';               s[t][4]='e';               s[t][5]='\0';               t++;               a2=0;            }            else            if((strcmp(a,"chopsticks")==0)&&a3)            {               for(j=0;j<10;j++)               {                   s[t][j]=s1[j];               }               s[t][j]='\0';               t++;               a3=0;            }            else            if((strcmp(a,"bowl")==0)&&a4)            {               s[t][0]='b';               s[t][1]='o';               s[t][2]='w';               s[t][3]='l';               s[t][4]='\0';               t++;               a4=0;            }        }        //printf("fdsjsk");        for(i=0;i<t;i++)        {            if(i!=t-1)            printf("%s ",s[i]);            else            printf("%s",s[i]);        }       printf("\n");    }}


 

0 0
原创粉丝点击