Please write code on C++ for following problem.
In the given string replace each sequence containing more than one space by one space.
For example: the string “a bcd ef . gh 90” - “a bcd ef . gh 90”
for (int i = 0; i < input.length(); i++) & if ( input[i] != ' ' || input[i+1] != ' ' ) // if current or next char output += input[i]; & & // is not space copy to output
Comments
Leave a comment