1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
#include <iostream> #include <algorithm> #include <queue> #include <vector> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> #include <ctime> #include <iomanip> #include <cmath> #include <set> using namespace std; int tel[10000000]; int main(){ int cnt = 0; cin >> cnt; while (cnt--) { char toProc[1000]; scanf(" %s",toProc); int len = strlen(toProc); int pow = 1000000,telnum = 0; for (int i = 0; i < len; i++) { if (isdigit(toProc[i])) { //digit telnum += pow * (toProc[i] - '0'); pow /= 10; }else if (isalpha(toProc[i])) { //alpha if (toProc[i] == 'Q' || toProc[i] == 'Z' ) { continue; } if (toProc[i] == 'A' || toProc[i] == 'B' || toProc[i] == 'C') { telnum += pow * 2; } if (toProc[i] == 'D' || toProc[i] == 'E' || toProc[i] == 'F') { telnum += pow * 3; } if (toProc[i] == 'G' || toProc[i] == 'H' || toProc[i] == 'I') { telnum += pow * 4; } if (toProc[i] == 'J' || toProc[i] == 'K' || toProc[i] == 'L') { telnum += pow * 5; } if (toProc[i] == 'M' || toProc[i] == 'N' || toProc[i] == 'O') { telnum += pow * 6; } if (toProc[i] == 'P' || toProc[i] == 'R' || toProc[i] == 'S') { telnum += pow * 7; } if (toProc[i] == 'T' || toProc[i] == 'U' || toProc[i] == 'V') { telnum += pow * 8; } if (toProc[i] == 'W' || toProc[i] == 'X' || toProc[i] == 'Y') { telnum += pow * 9; } pow /= 10; } } tel[telnum]++; //cout << telnum << endl; } bool flag = false; for (int i = 0; i < 10000000; i++) { if (tel[i] > 1) { flag = true; int pow = 1000000; int tmp = i; while (pow) { if (pow == 1000) { cout << '-'; } cout << tmp/pow; tmp -= (tmp/pow) * pow; pow /= 10; } cout << ' ' << tel[i] << endl; } } if (!flag) { cout << "No duplicates." << endl; } return 0; } |
真是良/心/题
首先要注意没有重复情形的时候,要输出一句话
然后以0开头的电话号码要处理
然后输入时候不能用cin
嗯就这样{(-_-)}