problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
lintcode::remove_extra::Solution类 参考

#include <lintcode.h>

静态 Public 成员函数

static string removeExtra (string &s)
 

详细描述

在文件 lintcode.h43 行定义.

成员函数说明

◆ removeExtra()

string lintcode::remove_extra::Solution::removeExtra ( string &  s)
static
参数
sthe original string
返回
: the string without arbitrary spaces

在文件 lintcode.cpp86 行定义.

86 {
87 auto output = ostringstream();
88 bool start = true;
89 bool flag = false;
90 for(const char c: s) {
91 if(c != ' ') {
92 if(flag && !start) {
93 output << ' ';
94 }
95 output << c;
96 start = false;
97 flag = false;
98 } else {
99 flag = true;
100 }
101 }
102 return output.str();
103 }

被这些函数引用 lintcode::remove_extra::TEST().


该类的文档由以下文件生成: