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

Re:电话号码翻译

Posted by linsir at 2013-09-25 13:23:29 on Problem 1002
In Reply To:Re:电话号码翻译 Posted by:20072631 at 2008-10-12 09:03:36
> 代码
> C
> #include<stdio.h>
> #include<string.h>
> struct unit
> {    int upset[2];
>   
>      int  count;
> }
> main()
>    {    struct unit b[1510];
> 
>        int i,j,flag1,flag2=0,flag3=0,m,n;
> 
>        static  int    k=0,temper,counter=0,temp[22];
> 
>       char number[22];
>         
>     static   int zancun[2];
> 
>    for(i=0;i<1510;i++)
>        {
>          b[i].upset[0]=-1;
> 
>          b[i].count=1;
>        }
> 
>           printf("Error:\n");           /*xian shu chu error*/
> 
>      while(gets(number)!=NULL)
> 
> 	{
>                if(number[0]!='3'&&number[0]!='6'
>                    &&number[0]!='D'&&number[0]!='E'
>                       &&number[0]!='F'&&number[0]!='M'
>                          &&number[0]!='N'&&number[0]!='O')
> 
>                   {
>                          abc:printf("%s\n",number);
> 
>                             flag2=1;
> 		            continue;
> 		   }              /*shou wei bu shi 3 6 zhi jie shu chu*/
> 	      else
>                      {
>                            
> 
>                    for(i=0,j=0,k=0;number[i]!='\0';i++)
> 
>                          {
> 			      if(number[i]=='A'||number[i]=='B'||
> 			      number[i]=='C'||
> 			      number[i]=='2')
> 	  	                         {
>                                               temp[k++]=2;j++; continue;
>                                           }
> 	  	              if(number[i]=='D'||number[i]=='E'||number[i]=='F'||number[i]=='3')
> 	  	                         {
>                                               temp[k++]=3;j++; continue;
>                                           }
> 	  	              if(number[i]=='G'||number[i]=='H'||number[i]=='I'||number[i]=='4')
> 	  	                         {
>                                                temp[k++]=4;j++;continue;
>                                           }
> 	  	                 if(number[i]=='J'||number[i]=='K'||number[i]=='L'||number[i]=='5')
> 	  	                           {
>                                                temp[k++]=5;j++; continue;
>                                             }
> 	  	                 if(number[i]=='M'||number[i]=='N'||number[i]=='O'||number[i]=='6')
> 	  	                           {
>                                                 temp[k++]=6;j++; continue;
>                                             }
> 	  	                if(number[i]=='P'||number[i]=='R'||number[i]=='S'||number[i]=='7')
> 	  	                            {
>                                                 temp[k++]=7;j++; continue;
>                                              }
> 	  	                if(number[i]=='T'||number[i]=='U'||number[i]=='V'||number[i]=='8')
> 	  	                            {
>                                                 temp[k++]=8;j++; continue;
>                                              }
> 	  	                if(number[i]=='W'||number[i]=='X'||number[i]=='Y'||number[i]=='9')
> 	  	                             {
>                                                  temp[k++]=9; j++; continue;
>                                               }
> 
>                                 if(number[i]=='1')
> 	  	                              {
>                                                     temp[k++]=1; j++; continue;
>                                               }
> 	  	                if(number[i]=='0')
> 	  	                              {
>                                                     temp[k++]=0; j++;continue;
>                                                }
> 	  	                 if(number[i]=='Q'||number[i]=='Z')
> 			                    goto abc;                /*ba shu zi yiyi dui ying */
> 
>                                  if(j>6)
> 
>                                              goto abc;                        /*pan duan wei shu*/
> 
>                                      temp[k]=-1;
> 	  	         }
> 		/*chu ru yi ge dian hua zhi*/
> 
>                        flag1=0;
>                    
>                        m=100*temp[0]+10*temp[1]+temp[2];
>     
>                    n=1000*temp[3]+100*temp[4]+10*temp[5]+temp[6];
> 
> 		  for(i=0;b[i].upset[0]!=-1;i++)
> 
>                      {
>                                    if(b[i].upset[0]==m)
>                                           
>                                            if(b[i].upset[1]==n)
>                                                    
>                                                 {
>                                                      (b[i].count)++;
> 
>                                                      flag1=1;
> 
>                                                       flag3=1;
>                                                  }
>                                        
> 	  	       }
> 	  	     if(flag1==0)
> 	  	                   {  
>                                        
>                  
>                                        b[counter].upset[0]=m;
>                                        
>                                       
>      
>                                        b[counter].upset[1]=n;
> 
>                                           counter++;
> 	  	                     }
> 	           }
>         }
> 	  	 if(flag2==0)
> 
> 	  	   printf("Not found.\n");
> 
> 		   printf("\nDuplication:\n");
> 
> 	  	 if(flag3==0)
> 
> 	  	    printf("Not found.\n");
> 
>                  else {
> 			  for(i=0;i<counter;i++)
> 
>                                    for(j=0;j<counter-1;j++ )
>                                         
>                                     {
>                                              if(b[i].upset[0]<b[j].upset[0])
>                   
>                                                   { 
>                                                    zancun[0] = b[i].upset[0];
>                                                    zancun[1]=b[i].upset[1];
>                                                    temper=b[i].count;
> 
> 
>                                                   b[i].upset[0]=b[j].upset[0];
>                                                   b[i].upset[1]=b[j].upset[1];
>                                                     b[i].count=b[j].count;
>                        
>                                                       
>                                                     b[j].upset[0]=zancun[0];
>                                                     b[j].upset[1]=zancun[1];
>                                                      b[j].count=temper;
>                                                   }
>                                             if(b[i].upset[0]==b[j].upset[0])
>                                                    {
>                                                           if(b[i].upset[1]<b[j].upset[1])
>                   
>                                                      { 
>                                                            zancun[0] = b[i].upset[0];
>                                                                zancun[1]=b[i].upset[1];
>                                                                temper=b[i].count;
> 
> 
>                                                              b[i].upset[0]=b[j].upset[0];
>                                                            b[i].upset[1]=b[j].upset[1];
>                                                              b[i].count=b[j].count;
>                        
>                                                       
>                                                                b[j].upset[0]=zancun[0];
>                                                               b[j].upset[1]=zancun[1];
>                                                                 b[j].count=temper;
>                                                         }
> 			                           }
>                                    }
>                     
> for(i=0;i<counter;i++)
> 	{
>             if(b[i].count!=1)
> 
> 	     {
> 		
> 			printf("%0.3d",b[i].upset[0]);
> 		          
>                         printf("-");
> 		
> 			  printf("%0.4d",b[i].upset[1]);
> 		
>                          printf(" %d\n",b[i].count);
> 
> 	      }
> 	 }
>                  
>   }
> }

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