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 |
兄弟们,我初来乍到,被这题弄的灰头灰脑的,大家帮忙解决一下,多谢下面是我的代码,大家帮帮忙 #include<stdio.h> #include<ctype.h> #include<string.h> #include<stdlib.h> #define num 100000 int cmp(const void *a,const void *b) { return *(long long *)a-*(long long *)b; } int main() { static long long phone[num]; long long times,time; long long duplicates=1; int ii,jj,kk; int judge=0; char a; int dic[26]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9}; scanf("%I64d",×); time=times ; phone[times-2]=-2;phone[times-1]=-2;phone[times]=-2;phone[times+1]=-2;phone[times+2]=-2;phone[times+3]=-2;/*防止出现0000000的情况*/ while(time--) { phone[time]=0; for(ii=7;ii>0;) { scanf("%1s",&a); if(isalnum(a)) { phone[time]=isalpha(a)?10*phone[time]+dic[a-'A']:10*phone[time]+a-'0'; ii--; } } } qsort(phone,times,sizeof(phone[0]),cmp); duplicates=1; for(jj=0;jj<times;jj++) { if(phone[jj]==phone[jj+1]) duplicates++; else { if(duplicates!=1) { printf("%d",phone[jj]/10000); printf("-"); printf("%d ",phone[jj]%10000); printf("%lld\n",duplicates); judge=1; duplicates=1; } } } if(!judge) 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