Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdio>
- #include<cstring>
- #include<string>
- #include<map>
- #include<vector>
- #include<algorithm>
- using namespace std;
- map<char,char> button;
- char tmp[123],tmp2[8];
- string tmp3;
- int dobel,now,t,n;
- int main(){
- button['A']='2'; button['B']='2'; button['C']='2';
- button['D']='3'; button['E']='3'; button['F']='3';
- button['G']='4'; button['H']='4'; button['I']='4';
- button['J']='5'; button['K']='5'; button['L']='5';
- button['M']='6'; button['N']='6'; button['O']='6';
- button['P']='7'; button['R']='7'; button['S']='7';
- button['T']='8'; button['U']='8'; button['V']='8';
- button['W']='9'; button['X']='9'; button['Y']='9';
- scanf("%d",&t); //printf("%d\n",t);
- for(int tc=0;tc<t;tc++){
- map<string,int> phone;
- vector<string> clone;
- dobel=0;
- scanf("%d",&n); //printf("%d\n",n);
- for(int i=0;i<n;i++){
- scanf("%s",tmp); now=0;
- for(int j=0;j<strlen(tmp);j++){
- if(tmp[j]>='A'&&tmp[j]<='Z'){
- tmp2[now]=button[tmp[j]]; now++;
- }else if(tmp[j]>='0'&&tmp[j]<='9'){
- tmp2[now]=tmp[j]; now++;
- }
- }
- tmp3=tmp2;
- phone[tmp3]++;
- //printf("%s %d\n",tmp2,phone[tmp3]);
- if(phone[tmp3]==2){
- dobel++; clone.push_back(tmp3);
- }
- }
- if(dobel==0){
- printf("No Duplicates.");
- }else{
- sort(clone.begin(),clone.end());
- for(int i=0;i<dobel;i++){
- printf("%s-%s %d",clone[i].substr(0,3).c_str(),clone[i].substr(3).c_str(),phone[clone[i]]);
- if(i<dobel-1) printf("\n");
- }
- }
- if(tc<t-1) printf("\n\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement