zoukankan      html  css  js  c++  java
  • POJ 3096 -- Surprising Strings

     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] = '';
    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_x86microsoft visual studio 9.0vcincludefunctional 143 Test
     
    在使用STL的容器(比如map)的insert方法时若出现上述错误,并且其他地方没有语法错误的话,多半是没有导入头文件#include <string>
  • 相关阅读:
    HTML DOM 12 表格排序
    HTML DOM 10 常用场景
    HTML DOM 10 插入节点
    HTML DOM 09 替换节点
    HTML DOM 08 删除节点
    HTML DOM 07 创建节点
    022 注释
    024 数字类型
    005 基于面向对象设计一个简单的游戏
    021 花式赋值
  • 原文地址:https://www.cnblogs.com/yxh-amysear/p/8594245.html
Copyright © 2011-2022 走看看