| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
请帮我看看哪里有问题, map 投机失败#include<iostream>
#include<map>
#include<string>
using namespace std;
char tmp[10000];
string s="1234567";
map<string,int> inch;
map<string,int>::const_iterator iter,begin,end;
int n,i,len;
int key[26] = {'2','2','2','3','3','3','4','4','4',
'5','5','5','6','6','6','7','7','7','7','8','8','8','9','9','9','9'};
int main()
{
cin>>n;
while(n--)
{
cin>>tmp;
len = 0;
for(i=0; tmp[i]!=0; i++)
if(tmp[i]<='9'&&tmp[i]>='0')
s[len++] = tmp[i];
else
if(tmp[i]<'Z'&&tmp[i]>='A')
s[len++] = key[tmp[i]-'A'];
if(inch.find(s)==inch.end())
inch[s] = 1;
else
inch[s] += 1;
}
begin = inch.begin();
end = inch.end();
while(begin!=end)
{
if(begin->second>1)
{
cout<<begin->first[0]<<begin->first[1]<<begin->first[2]<<"-"
<<begin->first[3]<<begin->first[4]<<begin->first[5]<<begin->first[6];
cout<<" "<<begin->second<<endl;
}
begin++;
}
// system("pause");
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator