Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- bool szukaj( std::string & tekst, std::string wyraz1, std::string wyraz2 )
- {
- size_t pozycja1 = tekst.find( wyraz1 );
- size_t pozycja2 = tekst.find( wyraz2 );
- if( pozycja1 != std::string::npos && pozycja2 != std::string::npos)
- {
- return true;
- }
- return false;
- }
- void wypiszWynik( bool czyZnaleziono )
- {
- if( czyZnaleziono )
- std::cout << "Znaleziono" << std::endl;
- else
- std::cout << "Nie znaleziono" << std::endl;
- }
- int main()
- {
- std::string napis = "Zadanie domowe z kursu C++ (http://cpp0x.pl) - najlepszy kurs C++ w Internecie!";
- wypiszWynik( szukaj( napis, "ada", "kurs" ) );
- wypiszWynik( szukaj( napis, "ada", "taki" ) );
- wypiszWynik( szukaj( napis, "C++", "cpp0x" ) );
- wypiszWynik( szukaj( napis, "C#", "cpp0x" ) );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment