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

我提交了个错误的程序,但是它AC了(附代码)

Posted by HJWAJ at 2010-07-08 10:40:58 on Problem 2608
#include<iostream>

using namespace std;

int main()
{
    char a[20];
    int b[20];
    
    //char temp[20];
    //cin>>temp;
    while (gets(a) != NULL)
    {
        int l=strlen(a);
    
        for(int n=0;n<l;n++)
        {
            //for(int j=0;j<20;j++)b[j]=0;
            //a[n]=temp[n];
            if (a[n]=='L')  b[n]=4;
            else if(a[n]=='R')  b[n]=6;
            else if(a[n]=='D'||a[n]=='T')  b[n]=3;
            else if(a[n]=='M'||a[n]=='N')  b[n]=5;
            else if(a[n]=='B'||a[n]=='F'||a[n]=='P'||a[n]=='V')  b[n]=1;
            else if(a[n]=='C'||a[n]=='G'||a[n]=='J'||a[n]=='K'||a[n]=='Q'||a[n]=='S'||a[n]=='X'||a[n]=='Z')  b[n]=2;
            else b[n]=0;
            //if(b[n]==b[n-1]&&b[n]!=0)  {b[n]=0;n--;}
            //if(b[0]!=0) printf("%d%s",b[0]," ")
           
           if(b[n]!=b[n-1] && b[n]!=0)
            printf("%d",b[n]);
        }
        cout<<endl;        
    }
    
    system("pause");
    return 0;    
}


当测试数据为CA;DDA;LLLA;MMMMA;RRRRRA时都是错的。。。求高手解释

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