zoukankan      html  css  js  c++  java
  • ZOJ 3207 80ers' Memory(strcmp函数的用法)

    80ers' Memory

    Time Limit: 1 Second      Memory Limit: 32768 KB

    I guess most of us are so called 80ers, which means that we were born in the 1980's. This group of people shared a lot of common memories. For example, the Saint Seiya, the YoYo ball, the Super Mario, and so on. Do you still remember these?

    Input

    There will be ONLY ONE test case.

    The test case begins with a positive integer N, (N < 100).
    Then there will be N lines each containing a single word describing a keyword of the typical 80ers' memories. Each word consists of letters, [a-zA-Z], numbers, [0-9], and the underline, '_'. The length of each word would be no more than 20.
    Then one line follows with a positive integer K, (K < 100).
    The last part of the test case will be K lines. The i-th line contains the keywords given by the i-th person and starts with a positive integer Ni. Then there will be Ni words separated by white spaces. Each of these words has no more than 20 characters.
    All the words are case sensitive.

    Output

    For each of these K people, you are asked to count the number of typical 80ers' keywords on his/her list and output it in a single line.

    Sample Input

    4
    Saint_Seiya
    YoYo_ball
    Super_Mario
    HuLuWa
    3
    2 Saint_Seiya TiaoFangZi
    1 KTV
    3 HuLuWa YOYO_BALL YoYo_ball
    

    Sample Output

    1
    0
    2
    

    Author: GAO, Fei
    Source: The 6th Zhejiang Provincial Collegiate Programming Contest

    #include <iostream>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    char str[105][25];
    int n,k;
    int main()
    {
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
            scanf("%s",&str[i]);
        scanf("%d",&k);
        for(int i=1;i<=k;i++)
        {
            int x,ans=0;
            scanf("%d",&x);
            for(;x>0;x--)
            {
                char ch[25];
                scanf("%s",&ch);
                for(int j=1;j<=n;j++)
                if (!strcmp(ch,str[j])) {ans++; break;}
            }
            printf("%d
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    websocket以及它的内部原理
    服务端向客户端推送消息的几种方式,基于ajax,队列以及异常处理实现简易版本的群聊功能(长轮询)
    分布式爬虫以及语言介绍
    去重以及布隆过滤器
    下载中间件,selenium集成
    【商城应用】商品运费流程设计
    引用本地jar包记得加扫描路径(注意重复bean)
    乐观锁悲观锁场景
    Linux时区
    JsonObject常用转换
  • 原文地址:https://www.cnblogs.com/stepping/p/6401158.html
Copyright © 2011-2022 走看看