map
代码如下
bool类型是默认为false
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
string s;
while(cin>>s){
if(s[0]=='*'&&s.size()==1) break;
if(s.size()==1||s.size()==2){
cout<<s<<" is surprising."<<endl; continue;
}
int flag=0;
for(int i=1;i<=s.size()-2;i++){
map<string,bool> p;
for(int j=0;j<s.size()-i;j++){
string temp;
temp+=s[j]; temp+=s[j+i];
if(!p[temp]){
p[temp]=true;
}
else {
flag=1;
break;
}
}
if(flag==1) {
break;
}
}
if(flag==0)
cout<<s<<" is surprising."<<endl;
else
cout<<s<<" is NOT surprising."<<endl;
}
}