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 here return result; } /**
C++
#include <string>
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 here
return 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 here
return result;
}
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)