Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void Find(string tekst,string wzor)
- {
- int a=0;
- for(int i=0;i<=tekst.length();i++)
- {
- if(tekst[i]==' ') continue; // Bez tego tez zadziala pomija odstepy
- for(int j=0;j<=wzor.length();j++)
- {
- if(wzor[j]!=tekst[i+j]&&(wzor[j]!='*'||tekst[i+j]==' ')) break;
- if((j+1)==wzor.length()) a++;
- }
- }
- if(a>0)
- {
- cout<<"Znaleziono "<<a<<" razy\n";
- }
- else
- {
- cout<<"Nie znaleziono\n";
- }
- }
- int main()
- {
- string tekst = "321 331 341 351 361 371";
- string wzor = "3*1";
- Find(tekst,wzor);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement