这个find为什么编译错误,不能这么用吗?
  • 板块学术版
  • 楼主happybob
  • 当前回复2
  • 已保存回复2
  • 发布时间2020/10/17 11:11
  • 上次更新2023/11/5 10:35:56
查看原帖
这个find为什么编译错误,不能这么用吗?
332914
happybob楼主2020/10/17 11:11
#include <cstdio>
#include <iostream>
#include <map>
#include <cstring>
using namespace std;

map <int, string> mp;

string v, name;

int x;

int main()
{
    int n, p, ans = 0;
    cin >> n >> p;
    for(int i = 1; i <= n; i++)
    {
        cin >> name >> x;
        mp[x] = name;
    }
    while(cin >> v)
    {
        map <int, string>::iterator it;
        it = mp.find(v);
        if(it != mp.end())
        {
            ans += (*it -> first);
        }
    }
    printf("%d\n", ans % p);
    return 0;
}
2020/10/17 11:11
加载中...