<<Maps-STL>> _HakerRank_C++_STL

#include <cmath>#include <cstdio>#include <vector>#include <iostream>#include <algorithm>#include <map> // insert the headerusing namespace std;int main() {    /* Enter your code here. Read input from STDIN. Print output to STDOUT */        int q = 0 , type = 0 , score = 0;    string name ;    map<string,int> m ;           cin >> q ;    for(int i = 0 ; i < q ; i++)    {        cin >> type ;                if(type == 1)         {            cin >> name >> score ;               m[name] += score ;         }        else if(type == 2)        {            cin >> name ;            m.erase(name) ;        }        else if(type == 3)        {            cin >> name ;            if( m.find(name) == m.end())            {                cout << "0\n" ;             }            else            {                cout << m[name] << endl ;            }        }    }            return 0;}

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章