2948. Phone Number

include

using namespace std;
int n;
string strs;
const string DIC=”22233344455566677778889999”;
map MAP;

string convert(string Ori) //Original
{
string ret=”“;
int ll=Ori.length();
for(int i=0;i>n;
for(int i=1;i<=n;i++)
{
cin>>strs;
MAP[convert(strs)]++;
}

map::iterator iter=MAP.begin();
while(iter!=MAP.end())
{
cout<<(iter).first<<’ ‘<<(iter).second<<endl;
++iter;
}
}

help!!
if(s[i][j]==’-‘)
{
for(k=j;k<a;k++) s[i][k]=s[i][k+1];
j–;
}

1、collections里的Counter类用于计数
2、str.maketrans函数用于建立字典映射
3、translate函数用于转换字符串

help!!
[em:02]

#include <bits/stdc++.h>
using namespace std;
string a = "22233344455566677778889999";
map<char,char> mp;      //字母到数字字符的映射
map<string,int> cnt;    //记录每个标准化的号码出现的次数

int main()
{
int n;
cin>>n;
for(int i = 0; i < 26; i++) {
mp['A'+i] = a[i];
}
string s;
while(n--) {
cin>>s;
string t;
for(int i = 0; i < s.length(); i++) {
if(!isdigit(s[i]) && s[i] != '-') t = t + mp[s[i]];
else if(s[i] == '-') continue;
else t = t + s[i];
}
t = t.insert(4,1,'-');      //插入'-'
cnt[t]++;
}

for(auto it = cnt.begin();it != cnt.end();it++) {
cout<<it->first<<" "<<it->second<<"\n";
}
return 0;
}