Question: C++ Assignment. Please help me to solve this code: #include #include using namespace std; string STUDENT = ; // Add your Canvas/occ-email ID #include h05.h
C++ Assignment. Please help me to solve this code:
#include
string STUDENT = ""; // Add your Canvas/occ-email ID
#include "h05.h"
// Place your function definitions in this file.
/** zipZap(str) removes the middle letters from all "zip" or "zap" strings.
@param str the input string. @return Look for patterns like "zip" and "zap" in the input string: any substring of length 3 that starts with "z" and ends with "p". Return a string where for all such words, the middle letter is gone, so "zipXzap" returns "zpXzp".
Here's a processing plan: 1. Save the length (len) and create an index (i = 0) 2. If len is less than 3, then we just return the input str 3. Write a while loop that goes while i is less than len 2 4. Inside the loop, extract a substring of 3 (word) 5. If word starts with 'z' and ends with 'p' then: - add "zp" to the output string - move forward three characters (to skip the "ip") 6. Otherwise - add the first character of word to the output string - move forward one character 7. After the loop, add the remaining characters, to the output */ string zipZap(const std::string& str)
{
//Put your code here
}
/** countCode(str) counts all occurences of the "code" pattern in str.
@param str the input string. @return the number of times that the string "code" appears anywhere in the given input string, except that we'll accept any letter for the 'd', so "cope" and both "cooe" count.
- countCode("aaacodebbb") returns 1
- countCode("codexxcode") returns 2
- countCode("cozexxcope") returns 2
{
//Put your code here
}
/** everyNth(str, n) calculates every nth character.
@param str the input string to check. @param n the n-th character to use @return the string made starting with char 0, and then every n-th char of the string. So, if n is 3, use char 0, 3, 6, and so on. If n is less than 1, return the empty string
*/ string everyNth(const std::string& str, int n)
{
//Put your code here
}
/** prefixAgain(str, n) returns true when the prefix(0,n) appears again in the string.
@param str the input string. @param n the number of characters to count for the prefix. @return consider the prefix string made of the first n characters of the input string. Does that prefix string appear somewhere else in the string? Assume that the string is not empty and that n is in the range 1..inStr.length().
Here's a plan: 1. Extract the first n characters into prefix 2. Start looping at 1, extracting n characters into word - if word is equal to prefix, return true 3. If we get through the loop, return false */ bool prefixAgain(const std::string& str, int n)
{
//Put your code here
}
////////////////// STUDENT TESTING ///////////// int run() { cout << "Student testing" << endl; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
