Question: //can anyone help me create these. ive done two so far //1st code no loops! //second code no loops! #include using namespace std; /** Mix

//can anyone help me create these. ive done two so far

//1st code no loops!

//can anyone help me create these. ive done two so far //1st

//second code no loops!

#include

using namespace std;

/** Mix two strings by alternating characters from them. If one string runs out before the other, just pick from the longer one. For example, mix("Fred", "Wilma") is "FWrieldma". Use recursion. Do not use loops. Hint: str.substr(1) is the substring of str from position 1 to the end. */ string mix(string a, string b) { }

//third code no loops!

#include

using namespace std;

/** Given a string, return a string of all lowercase letters contained in it. Use recursion. Do not use loops. A lowercase letter is a character between 'a' and 'z' inclusive. Hint: str.substr(1) is the substring of str from position 1 to the end. */ string lcl(string str) {

}

//4th code no loops!

code no loops! //second code no loops! #include using namespace std; /**

/* Write a recursive function to compute the number of bits in a nonnegative integer n. For example, bits(13) is 3 since 13 in binary is 1101.

Hint: The last bit of a number is 1 if the number is odd and 0 if the number is even. */ int bits(int n) { int count; int rem = n % 2; if(n 1 && rem == 0){return count + bits(n/2);} else if (n > 1 && rem == 1) { count++; return count + bits(n/2); } }

#include 3 using namespace std; Return true if the given string contains at least two different characters. Use recursion. Do not use loops Hint: If str[] is not the same as str[1], you have your answer.Otherwise, look at str.substr(1) (the substring of str from position 1 to the end) 10 12 bool someDifferent(string str) if((str.substr(0,1)!=str.substr(1))) // check different return true else return false | charater 14 15 16 17 18 19 20 21 //if true given contain least two different characters Submit Calling with Arguments fail pass pass pass fail fail Name Ealse fail someDifferent "aaa" pass someDifferent "aaba" pass someDifferent "baaa" pass someDifferent "aa fail someDifferent "b Ealse Ealse Ealse terminate called after throwing an instance of 'std::out of range what( basic string::substr: pos (which is 1) this-size (which is 0) timeout: the monitored command dumped core /opt/codecheck/runprog: line 33: 25130 Aborted fail someDifferent" tineout $ITIMEOUT)s nice $PROG Score 3/6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets tackle each of these problems one by one 1 Mixing Two Strings Recursive You need a function to mix two strings by alternating characters from each with recursion and no loops Heres how you can do ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!