| ||||||||||
| 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 | |||||||||
Re:这是1002题,哪位兄弟帮我看一下,不胜感激In Reply To:这是1002题,哪位兄弟帮我看一下,不胜感激 Posted by:hudedi at 2005-12-06 22:45:14 > 我这题的问题是WA,帮忙看一下
> #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,9};
> scanf("%I64d",×);
>
> time=times ;
> phone[times]=-2;phone[times+1]=-2;phone[times+2]=-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;
> if(times<2)
> {
> printf("No duplicates.\n");
> return 0;
>
> }
> 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("%I64d\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