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: 3886109 • 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();
string prefix = str.substr(0,n);

for(int i = n; i <= n; i++){

if(n + i <= len)
{
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) ×/yCS501DE G bool prefixAgain(cor X', D Ch05-writingFunct 0 (99) Deadmau5 + × x- × c Secure! https://ide.cs50.io/soctavio98/ide50#openfile-x CS50 IDE File Edit Find View Go Share × h08.h cs150 hw 72 bool prefixAgain(const string& str, int n) 74 int len str.lengthO; 75 string prefix - str.substr(o,n); h01 77 for(int i-n;

Explanation / Answer

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;
}