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;
    }

  • 相关阅读:
    java 截取pdf
    webService 发送soap请求,并解析返回的soap报文
    常用网址
    扫描文件夹下代码行数
    CodeMIrror 简单使用
    常用 linux 命令(部分)
    windows下RabbitMQ 监控
    一定要写的日志
    创业思路
    10月9日后计划
  • 原文地址:https://www.cnblogs.com/liudehao/p/4008606.html
Copyright © 2011-2022 走看看