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 kenhuang at 2008-07-21 09:32:41 on Problem 3096
#include <iostream>
using namespace std;
int main()
{
    char  str[80];
    while(scanf("%s",str),strcmp(str,"*")!=0)
    {
        int strl=strlen(str); 
        for(int i=1;i<=strl;i++)
        {
           int flag=0;
           for(int j=0;j<=i-2;j++)
           {
               for(int k=j+1;k<=strl-i;k++)
               if(str[j]==str[k]&&str[j+i]==str[k+i])  
               {cout<<str<<" is NOT surprising."<<endl;flag=1;break;}      
           }
           if(flag==1)  break;
           if(i==strl)  cout<<str<<" is surprising."<<endl;
        }                            
     }
     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