POJ 1002 487-3279

题目链接

map的应用

#include
#include
#include
#include
using namespace std;
int main(){
	int n;
	cin>>n;
	map m;
	map out;
	m['A']=m['B']=m['C']='2';
	m['D']=m['E']=m['F']='3';
	m['G']=m['H']=m['I']='4';
	m['J']=m['K']=m['L']='5';
	m['M']=m['N']=m['O']='6';
	m['P']=m['R']=m['S']='7';
	m['T']=m['U']=m['V']='8';
	m['W']=m['X']=m['Y']='9';
	while(n--){
		char s[100];
		cin>>s;
		string str;
		int k=0;
		for(int i=0;i='0'&&s[i]<='9') str+=s[i];
			else str+=m[s[i]];
			if(k==3) str+='-';
		} 
		out[str]++;
	}
	int flag=0;
	for(map::iterator it=out.begin();it!=out.end();it++){
		if(it->second>1){
			flag=1;
			cout<first<<" "<second<

你可能感兴趣的:(POJ)