Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- #include <math.h>
- #include <string>
- using namespace std;
- string s1,s2;
- void comparsion(string,string);
- int counter=0;
- int roz=0;
- int where=0;
- int main(){
- srand(time(0));
- getline(cin,s1);
- getline(cin,s2);
- comparsion(s1,s2);
- return 0;
- }
- void comparsion(string s1,string s2)
- {
- roz=s2.size();
- for(int i=0;i<=roz;i++)
- if(s2.find(s1,(where+i))!=string::npos)
- {
- counter++;
- where=s2.find(s1,(where+i));
- }
- cout<<"Pierwszy wyraz zawiera sie w drugim "<<counter<<" razy";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement