posts - 21,  comments - 9,  trackbacks - 0
3096暴力求解,0M通过
#include<stdio.h>
#include<iostream>
#include<cstring>
using namespace std;
char str[85];
char first[3],second[3];
int main()
{
 first[2]='\0',second[2]='\0';
 while(gets(str))
 {
  bool flag=true;
  if(str[0]=='*')
   break;
  int len=strlen(str);
  for(int i=0;i<len;i++)
  {//从第几个开始找起
   for(int j=1;j<(len-1)&&i+j<len;j++)
   {////////这个是间隔
    first[0]=str[i];first[1]=str[j+i];
    for(int k=i+1;k<len&&k+j<len;k++)
    {
     second[0]=str[k];second[1]=str[k+j];
     if(strcmp(first,second)==0)
      flag=false;
    }
    
   }
  }
  if(flag)
   cout<<str<<" is surprising."<<endl;
  else
   cout<<str<<" is NOT surprising."<<endl;
 }
 return 0;
}
posted on 2010-08-16 11:34 崔佳星 阅读(1076) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2010年8月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(1)

随笔分类

随笔档案

文章分类

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜