输入n个字符串

查询某个字符串出现次数

#include <cstdio>
#include <iostream>
#include <string>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

#define MAXN 10001
char str[MAXN];
map<string,int> h;
int n,m;

int main () {
    cin>>n>>m;
    for (int i=1;i<=n;i++) {
        scanf("%s",str);
        h[str]++;
    }
    for (int i=1;i<=m;i++) {
        scanf("%s",str);
        if (h.find(str)==h.end()) cout<<0<<endl;
        else cout<<h[str]<<endl;
    }

    return 0;
}

 

相关文章:

  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2021-06-25
相关资源
相似解决方案