zoukankan      html  css  js  c++  java
  • hdu1247 Hat’s Words 字符串模拟

      将每个字符串分割,查找,如果分割后的2个字符串均存在的话输出这个字符串。墨迹了一些。

     1 #include <map>
     2 #include <string>
     3 #include <iostream>
     4 using namespace std;
     5 int main()
     6 {
     7     string temp;
     8     string a[50000+10];
     9     string t1,t2;
    10     int l;
    11     map<string,int>haha;
    12     int k,i,j,q,cnt=0;
    13     while(cin>>temp)
    14     {
    15         haha[temp]++;
    16         a[cnt++]=temp;
    17     }
    18     for(k=0;k<cnt;++k)
    19     {
    20         l=a[k].length();
    21         if(l==1)
    22           continue;
    23         //把temp分成2部分,一部分长度是1~L-1,另一部分就是剩下的
    24         for(i=1;i<=l-1;++i)
    25         {
    26             t1="0";
    27             t2="0";
    28             for(j=1;j<i;++j)
    29              t1=t1+"0";
    30             for(j=1;j<l-i;++j)
    31              t2=t2+"0";
    32             for(j=0;j<i;++j)
    33             {
    34                 t1[j]=a[k][j];
    35             }
    36             for(j=i,q=0;j<l;++j,++q)
    37             {
    38                 t2[q]=a[k][j];
    39             }
    40             if(haha[t1]&&haha[t2])
    41             {
    42                 cout<<a[k]<<endl;
    43                 break;
    44             }
    45         }
    46     }
    47     return 0;
    48 
    49 }
  • 相关阅读:
    基本样式
    表单基础知识
    边框内圆角
    灵活的背景定位
    多重边框
    半透明边框
    变量关系
    闭包2——闭包与变量
    闭包
    基本包装类型
  • 原文地址:https://www.cnblogs.com/symons1992/p/2939924.html
Copyright © 2011-2022 走看看