Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int naiwny(int n,int m,string text,string wzorzec,int *wystepowanie)
- {
- int j=0;
- int i;
- //wystepowanie = new int[j];
- for(i=0;i<n-m+1;i++)
- {
- if(wzorzec == text.substr(i,m))
- {
- wystepowanie[j]=i;
- j++;
- cout<<"yy"<<endl;
- }
- }
- return j;
- }
- int main()
- {
- int j=0;
- string text = "ala ma kota";
- string wzorzec;
- int *wystepowanie;
- wystepowanie = new int[j];
- //cout << "Podaj tekst\n";
- //cin >> tekst;
- cout << "podaj wzorzec\n";
- getline(cin,wzorzec);
- int n=text.length();
- int m=wzorzec.length();
- j=naiwny( n, m, text, wzorzec, wystepowanie);
- for(int i=0; i<j; i++)
- {
- cout << wystepowanie[i] << endl;
- }
- delete[] wystepowanie;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement