Anonymous user
Split a character string based on change of character: Difference between revisions
Split a character string based on change of character (view source)
Revision as of 11:34, 25 February 2017
, 7 years agoUpdated C++ solution
(Added C++ Implementation) |
(Updated C++ solution) |
||
Line 213:
=={{header|C++}}==
<lang cpp>
// Solution for http://rosettacode.org/wiki/Split_a_character_string_based_on_change_of_character
#include<string>
#include<iostream>
std::string res ="";
for(
if(*it!=prev) {
if(!firstCommaPast) {
firstCommaPast = true;
} else {
res+=", ";
}
}
Line 234 ⟶ 235:
int main() {
std::
} </lang>▼
▲</lang>
{{out}}
<pre>g, HHH, 5, , )), YY, ++, ,,,, ///, \</pre>
|