C++ Program #include using std::string; /** * Problem 1: Simple strings & loops * * Given a string and an int n, create a new string * made of the first n characters of the original * string, followed by the first n-1 characters of * the original string, and so on. You may assume * that n is between 0 and the length of the string, * inclusive (i.e. n >= 0 and n <= str.length()) * * Some examples: * "Chocolate", 4 -> "ChocChoChC" * "Chocolate", 3 -> "ChoChC" * "Ice Cream", 2 -> "IcI" */ string decreasing(const string& str, int n) { string result = "not done"; // Add your code here return result; } /** * Problem 2: Intermediate Strings & Loops * * Given an input string, count the number of words ending * in 'y' or 'z' -so the 'y' in "heavy" and the 'z' in "fez" * count, but not the 'y' in "yellow". Make sure that your * comparison is not case sensitive. We'll say that a y * or z is at the end of a word if there is not an alphabetic * letter immediately following it. * * Do not use any string functions except for substr(), * at(), and size(), and isalpha() from . * * This is the most difficult problem in the set, * so do not start with this one. * * Here are some other examples: * - "fez day" -> 2 * - "day fez" -> 2 * - "day fyyyz" -> 2 */ int endzy(const string& str) { int result; // Add your code 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++ Program

#include <string>
using std::string;

/**
* Problem 1: Simple strings & loops
*
* Given a string and an int n, create a new string
* made of the first n characters of the original
* string, followed by the first n-1 characters of
* the original string, and so on. You may assume
* that n is between 0 and the length of the string,
* inclusive (i.e. n >= 0 and n <= str.length())
*
* Some examples:
* "Chocolate", 4 -> "ChocChoChC"
* "Chocolate", 3 -> "ChoChC"
* "Ice Cream", 2 -> "IcI"
*/
string decreasing(const string& str, int n)
{
string result = "not done";

// Add your code here

return result;
}

/**
* Problem 2: Intermediate Strings & Loops
*
* Given an input string, count the number of words ending
* in 'y' or 'z' -so the 'y' in "heavy" and the 'z' in "fez"
* count, but not the 'y' in "yellow". Make sure that your
* comparison is not case sensitive. We'll say that a y
* or z is at the end of a word if there is not an alphabetic
* letter immediately following it.
*
* Do not use any string functions except for substr(),
* at(), and size(), and isalpha() from <cctype>.
*
* This is the most difficult problem in the set,
* so do not start with this one.
*
* Here are some other examples:
* - "fez day" -> 2
* - "day fez" -> 2
* - "day fyyyz" -> 2
*/
int endzy(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 2 steps

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