码迷,mamicode.com
首页 > 其他好文 > 详细

map

时间:2019-01-31 13:09:38      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:元素   line   names   clu   str   类型   tchar   first   cst   

#include <map>
#include <iostream>
#include <cstdio>
#include <cctype>
using namespace std;
typedef long long ll;
map< ll, ll > mp;
inline ll read () {
    ll x=0,f=1;
    char ch=getchar();
    while(!isdigit(ch)) {
        if(ch==-) f=-1;
        ch=getchar();
    }
    while(isdigit(ch)) {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
int n;
signed main() {
    n=read();
    for(register int i=1; i<=n; i++) {
        ll x=read(),y=read();
        mp[x]=y;
    }
    for(map < ll , ll >::iterator it=mp.begin();it!=mp.end();it++){
        printf("mp[%lld]->%lld\n",it->first,it->second);
    }
    return 0;
//map< type1 , type2 >mp 两个类型 mp[type1]=type2
//mp.clear() 清空map
//mp.count(type1) 查找有没有这个元素
}

 

map

标签:元素   line   names   clu   str   类型   tchar   first   cst   

原文地址:https://www.cnblogs.com/qf-breeze/p/10341203.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!