Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

追星族

Posted by semonteer at 2005-10-05 10:20:07 on Problem 1002
In Reply To:求助:有错误吗? Posted by:sunmoon at 2005-10-05 09:20:16
> #include <string.h>
> char func1(char a)
> {
>     if(a>='A'&&a<='C') return '2';
>     else if(a>='D'&&a<='F') return '3';
>     else if(a>='G'&&a<='I') return '4';
>     else if(a>='J'&&a<='L') return '5';
>     else if(a>='M'&&a<='O') return '6';  
>     else if(a>='P'&&a<='S') return '7';  
>     else if(a>='T'&&a<='V') return '8';   
>     else if(a>='W'&&a<='Y') return '9';   
>     else return a;                  
> }    
> main()
> {
>     int i,j,k,num,m,flag=0;
>     scanf("%d",&num);
>     int qq[num];
>     int tm[num];
>     for(i=0;i<num;i++)  qq[i]=1;
>     char s[100000][20];  
>     for(i=0;i<num;i++)
>     {
>      scanf("%s",s[i]);
>      j=0;m=0;     
>      while(m<7)
>      {
>          while(s[i][j]=='-') j++;
>          s[i][m]=func1(s[i][j]);
>          m++;
>          j++;
>      }
>      s[i][m]='\0';      
>     }
>     int temp=num;   
>     for(i=0;i<temp-1;i++)  
>     if (s[i][0]!='Z')
>      for(j=i+1;j<temp;j++)
>       if(!strcmp(s[i],s[j]))
>        {
>            qq[i]+=1;
>            flag=1;
>            s[j][0]='Z';
>        }
>      m=0;
>      if(flag)     
>      {
>          for(i=0;i<num;i++)
>           if(qq[i]!=1) tm[m++]=i;
>          for(i=0;i<m-1;i++)
>           for(j=i+1;j<m;j++)
>            if(strcmp(s[tm[i]],s[tm[j]])>0) 
>            {k=tm[i];tm[i]=tm[j];tm[j]=k;}  
>          for(i=0;i<m;i++)
>            {
>               for(j=0;j<7;j++){if(j==3) printf("-"); printf("%c",s[tm[i]][j]);}
>               printf(" %d\n",qq[tm[i]]);
>            }                   
>      }      
>      else printf("No duplicates.\n");
>     system("PAUSE");   
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator