Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- void naive(string p, string t){
- int lengthT = t.length();
- int lengthP = p.length();
- for(int i=0; i < lengthT - lengthP;)
- {
- for(int k = 0; k< lengthP; k++){
- if(t[i+k] != p[k])
- {
- i++;
- break;
- }
- else if(k == lengthP-1)
- {
- cout<<i<<endl;
- i++;
- }
- }
- }
- }
- int main(){
- naive("ab", "aba");
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment