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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education