Question: 1 #include 2 using std::string; 3 4 /** 5 Problem 1: Simple strings & loops 6 7 Given a string and an int n, create

 1 #include 2 using std::string; 3 4 /** 5 Problem 1:Simple strings & loops 6 7 Given a string and an int

1 #include 2 using std::string; 3 4 /** 5 Problem 1: Simple strings & loops 6 7 Given a string and an int n, create a new string 8 made of the first n characters of the original 9 string, followed by the first n-1 characters of 10 the original string, and so on. You may assume 11 that n is between 0 and the length of the string, 12 inclusive (i.e. n >= 0 and n "ChocChoChc" 16 "Chocolate", 3 -> "ChoChc" 17 "Ice Cream", 2 -> "ICI" 18 */ 19 string decreasing(const string& str, int n) 20 { 21 string result = "not done"; 22 23 // Add your code here 24 25 return result; 26 } 27 * 8 /** 9 Problem 2: Intermediate Strings & Loops 0 1 Given an input string, count the number of words ending 2 in 'y' or 'z' -so the 'y' in "heavy" and the 'z' in "fez" 3 count, but not the 'y' in "yellow". Make sure that your 4 comparison is not case sensitive. We'll say that a y 5 or z is at the end of a word if there is not an alphabetic 6 letter immediately following it. 7 8 Do not use any string functions except for substr(), 9 at(), and size(), and isalpha() from . 0 1 This is the most difficult problem in the set, 2 so do not start with this one. 3 4 Here are some other examples: 5 - "fez day" -> 2 6 - "day fez" -> 2 7 - "day fyyyz" -> 2 8 */ 9 int endzy (const string& str) { 1 int result; 2 // Add your code here 3 4 5 return result; 6 }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!