C++
#include using std::string;/*** Problem 1: Simple strings & loops** Given an input string and a non-negative int n,* we'll say that the front of the string is the first* 3 chars, or whatever is there if the string is less* than length 3. Set result to n copies of the front** - for input of "Chocolate", 2 -> "ChoCho"* - for input of "Chocolate", 3 -> "ChoChoCho"* - for input of "Abc", 3 -> "AbcAbcAbc"*/string repeatFront(const string& str, int n){string result;// Your code goes herereturn result;}/*** Problem 2: Intermediate Strings & Loops** Given an input string, set result to the length of* the largest "block" in the string. A block is a run* of adjacent chars that are the same.** Do not use any string functions except for substr(),* at(), and size().** This is the most difficult problem in the set,* so do not start with this one.** Here are some other examples:* - for input of "hoopla" -> 2* - for input of "abbCCCddBBBxx" -> 3* - for input of "" -> 0*/int maxRun(const string& str){int result;// Add your code herereturn result;}
/*** Problem 1: Simple strings & loops** Given an input string and a non-negative int n,* we'll say that the front of the string is the first* 3 chars, or whatever is there if the string is less* than length 3. Set result to n copies of the front** - for input of "Chocolate", 2 -> "ChoCho"* - for input of "Chocolate", 3 -> "ChoChoCho"* - for input of "Abc", 3 -> "AbcAbcAbc"*/string repeatFront(const string& str, int n){string result;// Your code goes herereturn result;}
/*** Problem 2: Intermediate Strings & Loops** Given an input string, set result to the length of* the largest "block" in the string. A block is a run* of adjacent chars that are the same.** Do not use any string functions except for substr(),* at(), and size().** This is the most difficult problem in the set,* so do not start with this one.** Here are some other examples:* - for input of "hoopla" -> 2* - for input of "abbCCCddBBBxx" -> 3* - for input of "" -> 0*/int maxRun(const string& str){int result;// Add your code herereturn result;}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here