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 Acaini at 2009-07-27 11:28:47 on Problem 3096
#include<iostream>
using namespace std;
char s[100];
int main()
{
	int len,i,j,d,dmax;
	bool flag;
	while(scanf(" %s",&s)!=EOF && strcmp(s,"*"))
	{
		len=strlen(s);
		if(len<2) { printf("%s is surprising.\n",s); continue;}
		dmax=len-1;
		flag=true;
		for(d=1;d<=dmax ;d++)
			for(i=0;i<len && i+d<len ;i++)
				for(j=i+1;j<len && j+d<len;j++)
					if(s[j]==s[i] && s[j+d]==s[i+d]) {flag=false;goto dis;}

dis:;
		if(flag) printf("%s is surprising.\n",s);
		else printf("%s is NOT surprising.\n",s);
	}
	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