Unnamed
public text v1 · immutable#include <string>
string str = "a bc def";
string new_str = "";
int main()
{
for (int i = 0; i < length; i++)
{
if (str[i] == " ")
i += get_spaces_num(str, i) - 1;
new_str += str[i];
}
return 0;
}
int get_spaces_num(string str, int index)
{
int spaces_num = 0;
while (str[index++] == " ")
spaces_num++;
return spaces_num;
}