Question: need help with my hwk. dont know how to do prefixAgain. also can you check the rest of my problems are correct i feel like

need help with my hwk. dont know how to do prefixAgain. also can you check the rest of my problems are correct i feel like they are wrong.

here is the link of instructions and code down below and page starts at pg 18

https://drive.google.com/file/d/0B54VYuzeA502cm5lNklsTmdoME0/view?usp=sharing

-------------------------------------------------------------------------------

#include using namespace std;

string STUDENT = "soctavio"; // Add your Canvas/occ-email ID

#include "h08.h"

// Place your function definitions in this file.

string zipZap(const string& str) {

for(size_t i=0; len = str.size(); i 3) { return str; } }

while(i

if(word == "z" && str.at(i + 2) == "p") { str::append("zp"); i += 3; }

else { str::append(word); i++; } }

return str.substr(i);

}

int countCode(const string& str) { int result = 0;

//loop through str, grabbing 4 characters, substring each tiem for(size_t i = 4; len = str.size(); i

if(front == "co" && back == "e") result ++ }

return result; }

string everyNth(const string& str, int n) { string result = "";

for(size_t i = 0; len = str.subsize(); i

if (n

return result; }

bool prefixAgain(const string& str, int n) // not done {

return str.substr(1).find(str.substr(0,n)) != string::npos; }

 need help with my hwk. dont know how to do prefixAgain.also can you check the rest of my problems are correct ifeel like they are wrong. here is the link of instructions and

also if you need h08.h i post it down below. thank you

_______________________________________________

#ifndef H08_H_ #define H08_H_ /** @file h08.h @author Stephen Gilbert @version CS 150 */ #include /** 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".

  • zipZap("zipXzap") returns "zpXzp"
  • zipZap("zopzop") returns "zpzp"
  • zipZap("zzzopzop") returns "zzzpzp"

*/ std::string zipZap(const std::string& str);

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

*/ int countCode(const std::string& str);

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

  • everyNth("Miracle", 2) returns "Mrce"
  • everyNth("abcdefg", 2) returns "aceg"
  • everyNth("abcdefg", 3) returns "adg"

*/ std::string everyNth(const std::string& str, int n);

/** 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().

  • prefixAgain("abXYabc", 1) returns true
  • prefixAgain("abXYabc", 2) returns true
  • prefixAgain("abXYabc", 3) returns false

*/ bool prefixAgain(const std::string& str, int n);

#endif

Chrome File Edit View History Bookmarks People Window Help 0 *4)) 100% E , Sun 12:45 PM QE ncs 1 50-23378 x DCS 150 (69 un. YDch05-writingFX CS50 DE Gchegg Study CX a CS 150-C++rx CodingBat-Sol tavi C Secure | https://ide.cs50.io/soctavio98/ide50#openfile-x CS50 IDE File Edit Find View Go 115 9 Share h08.cpp h08.h h03 6 Finclude 3) 1 return str ic01B string word str.substr(3) if(nord- "z- str.at(i 2)-"p") + ic028 str::appendCord); 1+3 88:1 43 return str.substr); "?aAunt Find KAA Replace With Replace lace All Go h08/ A-PE02-Sample /workspace/cs15. /hw/hea/ s clear example1

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!