标签:
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 | #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; struct dataa{ char str[50]; bool operator < ( const dataa & a) const { return strcmp (a.str,str)>0; } }data[100010]; int main() { map< char , char > m; m[ ‘1‘ ] = ‘1‘ ; m[ ‘0‘ ] = ‘0‘ ; m[ ‘A‘ ] = m[ ‘B‘ ] = m[ ‘C‘ ] = m[ ‘2‘ ] = ‘2‘ ; m[ ‘D‘ ] = m[ ‘E‘ ] = m[ ‘F‘ ] = m[ ‘3‘ ] = ‘3‘ ; m[ ‘G‘ ] = m[ ‘H‘ ] = m[ ‘I‘ ] = m[ ‘4‘ ] = ‘4‘ ; m[ ‘J‘ ] = m[ ‘K‘ ] = m[ ‘L‘ ] = m[ ‘5‘ ] = ‘5‘ ; m[ ‘M‘ ] = m[ ‘N‘ ] = m[ ‘O‘ ] = m[ ‘6‘ ] = ‘6‘ ; m[ ‘P‘ ] = m[ ‘R‘ ] = m[ ‘S‘ ] = m[ ‘7‘ ] = ‘7‘ ; m[ ‘T‘ ] = m[ ‘U‘ ] = m[ ‘V‘ ] = m[ ‘8‘ ] = ‘8‘ ; m[ ‘W‘ ] = m[ ‘X‘ ] = m[ ‘Y‘ ] = m[ ‘9‘ ] = ‘9‘ ; m[ ‘-‘ ] = m[ ‘Q‘ ] = m[ ‘Z‘ ] = ‘-‘ ; char str[50]; int t; scanf ( "%d" ,&t); for ( int i = 0 ; i < t ;i++){ scanf ( "%s" ,str); char *p = str; int pos = 0; while (*p){ if (pos == 3) data[i].str[pos++] = ‘-‘ ; if (m[*p] != ‘-‘ ) data[i].str[pos++] = m[*p]; p++; } } sort(data,data + t); int ct = 1; int kk = 0; for ( int i = 1 ; i < t ;i++){ if (!(data[i] < data[i-1]) && !(data[i-1] < data[i])) ct++; else if (ct > 1){ printf ( "%s %d\n" ,data[i - 1].str,ct); kk++; ct = 1; } } if (ct > 1){ printf ( "%s %d\n" ,data[t- 1].str,ct); kk++; ct = 1; } if (!kk) printf ( "No duplicates.\n" ); return 0; }
|
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 | #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; int main() { map< char , char > m; map<string, int > mp; m[ ‘1‘ ] = ‘1‘ ;m[ ‘0‘ ] = ‘0‘ ; m[ ‘A‘ ] = m[ ‘B‘ ] = m[ ‘C‘ ] = m[ ‘2‘ ] = ‘2‘ ; m[ ‘D‘ ] = m[ ‘E‘ ] = m[ ‘F‘ ] = m[ ‘3‘ ] = ‘3‘ ; m[ ‘G‘ ] = m[ ‘H‘ ] = m[ ‘I‘ ] = m[ ‘4‘ ] = ‘4‘ ; m[ ‘J‘ ] = m[ ‘K‘ ] = m[ ‘L‘ ] = m[ ‘5‘ ] = ‘5‘ ; m[ ‘M‘ ] = m[ ‘N‘ ] = m[ ‘O‘ ] = m[ ‘6‘ ] = ‘6‘ ; m[ ‘P‘ ] = m[ ‘R‘ ] = m[ ‘S‘ ] = m[ ‘7‘ ] = ‘7‘ ; m[ ‘T‘ ] = m[ ‘U‘ ] = m[ ‘V‘ ] = m[ ‘8‘ ] = ‘8‘ ; m[ ‘W‘ ] = m[ ‘X‘ ] = m[ ‘Y‘ ] = m[ ‘9‘ ] = ‘9‘ ; m[ ‘-‘ ] = m[ ‘Q‘ ] = m[ ‘Z‘ ] = ‘-‘ ; char str[50]; int t; scanf ( "%d" ,&t); for ( int i = 0 ; i < t ;i++) { scanf ( "%s" ,str); char *p = str; char tmp[50]; int pos = 0; while (*p) { if (pos == 3) { tmp[pos++] = ‘-‘ ; } if (m[*p] != ‘-‘ ) tmp[pos++] = m[*p]; p++; } tmp[pos] = ‘\0‘ ; mp[string(tmp)]++; } int kk = 0; map<string, int >::iterator it; for (it = mp.begin();it != mp.end();it++) { if (it->second > 1){ printf ( "%s %d\n" ,(it->first).data(),it->second); kk++; } } if (!kk) printf ( "No duplicates.\n" ); return 0; } |
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/5142870.html