[模板] map

题目地址

#include<bits/stdc++.h>
using namespace std;
int main() {
    map <int,int> a;  //把它看成数组
    set <int> b;
    int n,i,q;
    cin>>n;
    for(i=1; i<=n; i++) {
        scanf("%d",&q);
        a[q]++;
        b.insert(q);
    }
    for(set<int>::iterator it=b.begin(); it!=b.end(); it++) //迭代器
        printf("%d %d\n",*it,a[*it]);
}

  

 

TRANSLATE with x English
Arabic Hebrew Polish
Bulgarian Hindi Portuguese
Catalan Hmong Daw Romanian
Chinese Simplified Hungarian Russian
Chinese Traditional Indonesian Slovak
Czech Italian Slovenian
Danish Japanese Spanish
Dutch Klingon Swedish
English Korean Thai
Estonian Latvian Turkish
Finnish Lithuanian Ukrainian
French Malay Urdu
German Maltese Vietnamese
Greek Norwegian Welsh
Haitian Creole Persian  
[模板] map [模板] map [模板] map [模板] map   TRANSLATE with [模板] map COPY THE URL BELOW [模板] map [模板] map Back EMBED THE SNIPPET BELOW IN YOUR SITE [模板] map Enable collaborative features and customize widget: Bing Webmaster Portal Back
上一篇:leetcode 2097. 合法重新排列数对


下一篇:C++ 去除重复项且获取到不重复部分