zoukankan      html  css  js  c++  java
  • C++ split

    /*************************************************
    Function: split
    Description: 根据空格切分字符串
    Calls: // 被本函数调用的函数清单
    Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
    Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
    Input: // 输入参数说明,包括每个参数的作
    // 用、取值说明及参数间关系。
    Output: // 对输出参数的说明。
    Return: // 函数返回值的说明
    Others: // 其它说明
    *************************************************/
    vector<string> split(const string &s, const string &seperator) {
      vector<string> result;
      typedef string::size_type string_size;
      string_size i = 0;

      while (i != s.size()) {
        //找到字符串中首个不等于分隔符的字母;
        int flag = 0;
        while (i != s.size() && flag == 0) {
          flag = 1;
          for (string_size x = 0; x < seperator.size(); ++x)
            if (s[i] == seperator[x]) {
              ++i;
              flag = 0;
              break;
            }
        }

        //找到又一个分隔符,将两个分隔符之间的字符串取出;
        flag = 0;
        string_size j = i;
        while (j != s.size() && flag == 0) {
          for (string_size x = 0; x < seperator.size(); ++x)
            if (s[j] == seperator[x]) {
              flag = 1;
              break;
            }
            if (flag == 0)
              ++j;
          }
          if (i != j) {
            result.push_back(s.substr(i, j - i));
            i = j;
          }
        }
      return result;
    }

  • 相关阅读:
    [Codeforces 339D] Xenia and Bit Operations
    [Codeforces 459D] Pashmak and Parmida's problem
    [Codeforces 460C] Present
    [Codeforces 466C] Number of Ways
    [Codeforces 650A] Watchmen
    Linux系统中‘dmesg’命令处理故障和收集系统信息的7种用法
    select函数详解
    都是stm32的JTAG引脚惹的祸
    uboot中的快捷菜单的制作说明
    卷积的本质及物理意义(全面理解卷积)
  • 原文地址:https://www.cnblogs.com/herd/p/9889204.html
Copyright © 2011-2022 走看看