poj3096 题不难,题面很难

就是看相邻一定位置的两个char组成的字符串是不是出现过。

 1 #include <iostream>
 2 #include <map>
 3 using namespace std;
 4 string str;
 5 map<string,int>haha;
 6 bool check(int n)
 7 {
 8     haha.clear();
 9     int l=str.length();
10     int i,j;
11     string t="11";
12     for(i=0;i<l-n-1;++i)
13     {
14         t[0]=str[i];
15         t[1]=str[i+n+1];
16         if(haha[t])
17             return 0;
18         haha[t]=1;
19     }
20     return 1;
21 }
22 bool check1()
23 {
24     int i;
25     int l=str.length();
26     for(i=0;i<=l-2;++i)
27     {
28         if(!check(i))
29             return 0;
30     }
31     return 1;
32 }
33 int main()
34 {
35     while(cin>>str&&str!="*")
36     {
37         if(check1())
38             cout<<str<<" is surprising."<<endl;
39         else
40             cout<<str<<" is NOT surprising."<<endl;
41     }
42     return 0;
43 }
原文地址:https://www.cnblogs.com/symons1992/p/3046165.html