Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
C code#include <stdio.h> #include <stdlib.h> const char map[26] = { '2', '2', '2', '3', '3', '3', '4', '4', '4', '5', '5', '5', '6', '6', '6', '7', '\0', '7', '7', '8', '8', '8', '9', '9', '9' }; int set[100000]; int setLen = 0; int _cmp(const void* e1, const void* e2) { return ( *((int*)e1) - *((int*)e2) ); } int main() { int i, n, t, pos, flag; char tstr[64]; scanf("%d", &n); while (n > 0) { scanf("%s", tstr); pos = 0; for (i = 0; pos < 7; ++i) if ( tstr[i] >= 'A' && tstr[i] <= 'Y' && tstr[i] != 'Q' ) tstr[pos++] = map[tstr[i]-'A']; else if ( tstr[i] >= '0' && tstr[i] <= '9' ) tstr[pos++] = tstr[i]; tstr[pos] = '\0'; sscanf(tstr, "%d", &t); set[setLen++] = t; --n; } qsort(set, setLen, sizeof(int), _cmp); flag = 1; for (i = 0; i < setLen - 1; ++i) { t = 1; while (set[i] == set[i+1]) { ++i; ++t; } if (t > 1) { printf("%03d-%04d %d\n", set[i]/10000, set[i]%10000, t); flag = 0; } } if (flag) printf("No duplicates. \n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator