Please Help Beginner !

I need a code that outputs this only using

string interleave( const string & s1, const string & s2



interleave( "Supercalifragilistic", "Mary" ) returns "SMuapreyrcalifragilistic"

Please Help Thank you in advance
Please note, this is not a homework solution site. We are more than happy to provide help, but the purpose of programming assignments is to get practice.

Basically, you need to place the characters in string 2 into random places in string 1. Can you think of a series of steps that would accomplish that?
Suppose you had two rows of blocks in front of you and you wanted to interleave them. How would you do that?

A lot of the practice is coming up with the series of steps.
Im stuck here, Please Help JayZom

#include <iostream>
#include <string>

int main ()
{
std::string str="Supercalifragilistic";
std::string str2="Mary";

std::string::iterator it;


str.insert(1,str2);
//str.insert(1,);

std::cout << str << '\n';
return 0;
}
Build a new string, alternating characters from each string.

insert will have no part in your solution unless you enjoy complicating things. ;)
Yup yup. All you need for this one is string concatenation. Also you don't need an iterator. You can literally do for loops and access strings at whatever character indices you want to add "Mary".
Topic archived. No new replies allowed.