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 |
贴一段ac码<code> #include <stdio.h> #include <memory.h> #define LN 10000000 #define LM 300 int a[LN]; int main() { int i=0; char num[LM]; char *p; int pont; int count; int hg,low; int pc=0; memset(a,0,sizeof(int)*LN); scanf("%d",&count); for(i=0;i<LM;i++) { num[i] = 0; } for(i=0;i<count;i++) { scanf("%s",num); pont = 0; for(p = num;p<num+LM;p++) { if(*p <= 'z' && *p >= 'a') { *p -= 32; } else if(*p == '\0') { break; } switch(*p) { case '0': pont = pont*10; break; case '1': pont = pont*10+1; break; case 'A':case 'B':case 'C':case '2': pont = pont*10+2; break; case 'D':case 'E':case 'F':case '3': pont = pont*10+3; break; case 'G':case 'H':case 'I':case '4': pont = pont*10+4; break; case 'J':case 'K':case 'L':case '5': pont = pont*10+5; break; case 'M':case 'N':case 'O':case '6': pont = pont*10+6; break; case 'P':case 'R':case 'S':case '7': pont = pont*10+7; break; case 'T':case 'U':case 'V':case '8': pont = pont*10+8; break; case 'W':case 'X':case 'Y':case '9': pont = pont*10+9; break; } } a[pont] ++; } //遍历输出 for(i=0;i<LN;i++) { if(a[i]>1) { hg = i/10000; low = i%10000; printf("%03d-%04d %d\n",hg,low,a[i]); pc++; } } if(0==pc) { printf("No duplicates.\n"); } return 0; } </code> Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator