Combine Strings

From Hack Wars Wiki

Jump to: navigation, search

Outdated, should be deleted. - aoi

Challenge Information for Combine Strings
Challenge Combine Strings
Code 9
Input Example HloWrd,el ol (String)
Output Example Hello World (String)
Level 0
Profit $0
Experience 0 to each stat
Description Combine two strings together.


Solution

string stringOne = getInputString();
string stringTwo = getInputString();
string stringEnd = "";
int lenOne = strlen(stringOne);
int lenTwo = strlen(stringTwo);
int i = 0;
 
while(i < lenOne + 2)
{
	if(i < lenOne)
	{
		stringEnd = stringEnd + substr(stringOne, i, i + 1);
	}
 
	if(i < lenTwo)
	{
		stringEnd = stringEnd + substr(stringTwo, i, i + 1);
	}
 
	i++;
}
 
setOutputString(stringEnd);
Personal tools