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

不知为何,就是WA,请指教

Posted by vcjsp at 2011-02-06 11:08:13 on Problem 3981
    char src[]="you";
    char dst[]="we";
    int len_src=strlen(src);
    int len_dst=strlen(dst);
    char s[1001];
    char result[1001];
    int index_s;
    int index_result;
    int i;
    int len;
    while(gets(s)!=NULL)
    {
        len=strlen(s);
        index_s=0;
        index_result=0;
        while(index_s<len)
        {
            for(i=0; i<len_src; i++)
            {
                if(s[index_s]!=src[i])
                {
                    result[index_result++]=s[index_s++];
                    break;
                }
                else
                {
                    index_s++;
                }
            }
            if(i==len_src)
            {
                strcpy(&result[index_result],dst);
                index_result+=len_dst;
            }
        }
        result[index_result]='\0';
        printf("%s\n",result);
    }

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