Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this the the link of instructions it starts page 25 https://drive.google.com/fil

ID: 3886144 • Letter: T

Question

this the the link of instructions it starts page 25

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

how can i fix this to get 100 percent. please rewrite the code or fix it

bool prefixAgain(const string& str, int n)
{
int len = str.length();bool prefixAgain(const string& str, int n)
{
int len = str.length();
string prefix = str.substr(0,n);
for(int i = n; n+i <= len; i++)
{
if(prefix == str.substr(i, i + n))
{
return true;
}
}
return false;
}

Chrome File Edit View History Bookmarks People Window Help O cS1 50-23378C- RCS 150 (69 unread) cs501DE x

Explanation / Answer

bool prefixAgain(const string& str, int n)
{
int len = str.length();
string prefix = str.substr(0,n);
//cout<<prefix<<endl;
//cout<<str.substr(1,2)<<endl;
for(int i = n; n+i <= len; i++)
{
//cout<<i<<" "<<n<<endl;
//cout<<str.substr(i,n)<<endl;
if(prefix == str.substr(i,n))
{
return true;
}
}
return false;
}