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++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

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;
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr