POJ 3096 -- Surprising Strings
1 #include<iostream> 2 #include<map> 3 #include<cstring> 4 #include<string> 5 using namespace std; 6 char str[80]; 7 bool solve() 8 { 9 for(int i=0;i<strlen(str)-2;i++)//D的长度 10 { 11 map<string,int> flag; 12 for(int j=0;j<strlen(str)-i-1;j++) 13 { 14 string ss = "AA"; 15 ss[0] = str[j];ss[1] = str[j+i+1];ss[2] = ‘\0‘; 16 if(!flag[ss])//没有重复 17 { 18 flag[ss] = 1; 19 } else{//重复 20 return false; 21 } 22 } 23 flag.clear(); 24 } 25 return true; 26 } 27 28 int main() 29 { 30 31 while(true) 32 { 33 cin>>str; 34 if(str[0] == ‘*‘) break; 35 if(strlen(str) <= 2) 36 { 37 cout<<str<<" is surprising."<<endl; 38 }else{ 39 if(!solve()) cout<<str<<" is NOT surprising."<<endl; 40 else cout<<str<<" is surprising."<<endl; 41 } 42 43 } 44 return 0; 45 }
Error 42 error C2784: ‘bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)‘ : could not deduce template argument for ‘const std::_Tree<_Traits> &‘ from ‘const std::string‘ d:\program files_x86\microsoft visual studio 9.0\vc\include\functional 143 Test
在使用STL的容器(比如map)的insert方法时若出现上述错误,并且其他地方没有语法错误的话,多半是没有导入头文件#include <string>