http://poj.org/problem?id=3096
题意容易理解,开始直接暴力,还是用map写下吧,熟练一下;
#include<stdio.h>
#include<string.h>
#include<string>
#include<map>
using namespace std; int main()
{
char s[];
char t[];
int n,i;
map <string,int> mymap; while(~scanf("%s",s))
{
if(s[] == '*')
break; n = strlen(s);
bool flag = true;
int start,end; for(i = ; i <= n- &&flag; i++)
{
mymap.clear();
for(start = ,end = start+i+; end < n;start++,end++)
{
t[] = s[start];
t[] = s[end];
t[] = '\0';
if(mymap[t] != )
{
flag = false;
break;
}
else
mymap[t]++;
}
}
if(flag)
printf("%s is surprising.\n",s);
else printf("%s is NOT surprising.\n",s);
}
return ;
}