Advertisement
Guest User

755

a guest
Jul 31st, 2014
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include<cstdio>
  2. #include<cstring>
  3. #include<string>
  4. #include<map>
  5. #include<vector>
  6. #include<algorithm>
  7.  
  8. using namespace std;
  9.  
  10. map<char,char> button;
  11. char tmp[123],tmp2[8];
  12. string tmp3;
  13. int dobel,now,t,n;
  14.  
  15. int main(){
  16. button['A']='2'; button['B']='2'; button['C']='2';
  17. button['D']='3'; button['E']='3'; button['F']='3';
  18. button['G']='4'; button['H']='4'; button['I']='4';
  19. button['J']='5'; button['K']='5'; button['L']='5';
  20. button['M']='6'; button['N']='6'; button['O']='6';
  21. button['P']='7'; button['R']='7'; button['S']='7';
  22. button['T']='8'; button['U']='8'; button['V']='8';
  23. button['W']='9'; button['X']='9'; button['Y']='9';
  24.  
  25. scanf("%d",&t); //printf("%d\n",t);
  26. for(int tc=0;tc<t;tc++){
  27. map<string,int> phone;
  28. vector<string> clone;
  29. dobel=0;
  30. scanf("%d",&n); //printf("%d\n",n);
  31. for(int i=0;i<n;i++){
  32. scanf("%s",tmp); now=0;
  33. for(int j=0;j<strlen(tmp);j++){
  34. if(tmp[j]>='A'&&tmp[j]<='Z'){
  35. tmp2[now]=button[tmp[j]]; now++;
  36. }else if(tmp[j]>='0'&&tmp[j]<='9'){
  37. tmp2[now]=tmp[j]; now++;
  38. }
  39. }
  40. tmp3=tmp2;
  41. phone[tmp3]++;
  42. //printf("%s %d\n",tmp2,phone[tmp3]);
  43. if(phone[tmp3]==2){
  44. dobel++; clone.push_back(tmp3);
  45. }
  46. }
  47.  
  48. if(dobel==0){
  49. printf("No Duplicates.");
  50. }else{
  51. sort(clone.begin(),clone.end());
  52. for(int i=0;i<dobel;i++){
  53. printf("%s-%s %d",clone[i].substr(0,3).c_str(),clone[i].substr(3).c_str(),phone[clone[i]]);
  54. if(i<dobel-1) printf("\n");
  55. }
  56. }
  57. if(tc<t-1) printf("\n\n");
  58. }
  59.  
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement