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 fumeng2005 at 2008-07-14 20:12:21 on Problem 2608
#include<stdio.h>
#include<stdlib.h>
main()
{
   char a[30];
   int b[30];
   int i=0,j=0;
   while(j<=30)
   {
      a[i]='0';
      b[j]=0;
      j++;
   }
   while(scanf("%s",&a)!=EOF)
   {  
      int l=strlen(a);
      i=0;
      while(i<=l)
      {
         switch (a[i])
         {
            case 'B':case 'F':case 'P':case 'V':b[i]=1;break; 
      
               case 'C':case 'G':case 'K':case 'Q':case 'S':case 'X':case 'Z': case 'J':b[i]=2;break; 
      
            case 'D':case 'T':b[i]=3;break; 
      
            case 'L':b[j]=4;break;
      
            case 'M':case 'N':b[i]=5;break; 
      
            case 'R':b[i]=6;break;   
            
            defalt:break;
         }
         i++;
      }
      i=0;
      while(i<=l)
      {
         if((i==0)&&(b[i]!=0))
            printf("%d",b[i]);
         else if((i!=0)&&(b[i]!=b[i-1])&&(b[i]!=0))
            printf("%d",b[i]);
         i++;
      }
      printf("\n");
      j=0;
      while(j<=l)
      {
         a[i]='0';
         b[j]=0;
         j++;
      }
      i=0;
   }
   system("pause");
   return 0;
}

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