| ||||||||||
| 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:和标程几乎完全一样的程序,却WA,牛人来看看In Reply To:和标程几乎完全一样的程序,却WA,牛人来看看 Posted by:qwert123 at 2006-04-27 11:07:47 > 用C写的,但是要用C++来提交,因为有用到new,用C提交的话会CE
> 和那个经典标程算法一样,其实几乎是一模一样的,实在想不通为什么WA,或者大家再多给我几组BT数据我看看,多谢了!
> #include<stdio.h>
> #include<stdlib.h>
>
> int compare(const void * a,const void * b)
> {
> return (*(int*)a-*(int*)b);
> }
>
> void main()
> {
> int ins,in,i,j,count,total=0;
> const char con[]="22233344455566677778889999";
> char org[100],tra[8];
> int *std;
> scanf("%d",&ins);
> std=new int[ins];
> for(in=0;in<ins;in++)
> {
> scanf("%s",org);
> j=0;
> for(i=0;org[i]!='\0';i++)
> {
> if (org[i]>='A' && org[i]<='Z')
> {tra[j]=con[org[i]-'A'];j++;continue;}
> if (org[i]>='0' && org[i]<='9')
> {tra[j]=org[i];j++;}
>
> }
> std[in]=atoi(tra);
> }
> qsort(std,ins,sizeof(int),compare);
> for(i=0;i<ins;i++)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~for(i=0;i<ins;)
> {
> count=1;
> for(j=i+1;j<ins && std[j]==std[i];j++)
> count++;
> if (count>1)
> {
> printf("%03d-%04d %d\n",std[i]/10000,std[i]%10000,count);
> total=1;
> }
> i=j;
> }
> if (total==0)
> printf("No duplicates.\n");
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator