zoukankan      html  css  js  c++  java
  • BNU Online Judge-34776-What does the fox say?

    题目链接

    http://www.bnuoj.com/bnuoj/problem_show.php?pid=34776

    题意: fox 的叫声  

    例如测试用例

    输入

    toot woof wa ow ow ow pa blub blub pa toot pa blub pa pa ow pow toot
    dog goes woof
    fish goes blub
    elephant goes toot
    seal goes ow
    what does the fox say?

    输出

    wa pa pa pa pa pa pow

    这样理解就是其他动物没有叫过的声音就是fox叫的例如把toot woof wa ow ow ow pa blub blub pa toot pa blub pa pa ow pow toot 中woof   blub   toot  ow

    去掉就是答案。

    代码

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<map>
    #include<string>
    using namespace std;
    map<string,int>M;
    int main()
    {
    int t;
    scanf("%d",&t);
    char s1[11000];
    char ss[150];
    char sss[110][110];
    map<char,int>::iterator it;
    while(t--)
    {
    getchar();
    gets(s1);
    int k=0;
    M.clear();
    memset(sss,'',sizeof(sss));
    while(scanf("%s",ss)&&strcmp(ss,"say?")!=0)
    {
    k++;
    if(k%3==0)
    {
    M[ss]=1;
    }
    }
    //it=M.end();
    //printf("%d ",M.size());
    //it=M.find("the");
    M.erase(M.end(),M.end());
    int len=strlen(s1);
    int ans=0;
    for(int i=0; i<len; i++)
    {
    if(s1[i]==' ')
    {
    ans++;
    continue;
    }
    char d[10];
    d[0]=s1[i];
    d[1]='';
    strcat(sss[ans],d);
    }
    int flag=0;
    for(int i=0; i<=ans; i++)
    {
    if(!M[sss[i]])
    {
    if(flag==0)
    {
    printf("%s",sss[i]);
    flag++;
    }
    else
    printf(" %s",sss[i]);
    }
    }
    printf(" ");
    }
    return 0;
    }

  • 相关阅读:
    Linux用root强制踢掉已登录用户;用fail2ban阻止ssh暴力破解root密码
    JDBC开发
    JSP指令与动作元素
    Jsp——状态管理
    JavaBeans
    JSP——九大内置对象
    Jsp基础语法
    WEB-INF目录结构
    JavaWeb简介
    UML——初识
  • 原文地址:https://www.cnblogs.com/liudehao/p/4008606.html
Copyright © 2011-2022 走看看