POJ-3096 Surprising Strings
程序员文章站
2022-06-04 08:14:00
...
POJ-3096 Surprising Strings
题目链接:POJ-3096
题目大意:这题题意我不会描述…
解题思路:利用map进行查找 利用goto跳出循环
代码块:
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main(){
string strA;
while(cin>>strA,strA[0]!='*'){
map<string, bool> mapA;
bool isT = true;
// 当前需要跨过字符的控制
for(int i = 1; i < strA.length(); i++){
for(int j = 0; j < strA.length() - i; j++){
string strB = "";
strB += strA[j];
strB += strA[j+i];
if(!mapA[strB]){
mapA[strB] = true;
}else{
isT = false;
goto there;
}
}
mapA.clear();
}
there:{
if(isT)cout<<strA<<" is surprising."<<endl;
else cout<<strA<<" is NOT surprising."<<endl;
}
}
return 0;
}