Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- class Program
- {
- static bool czyIstnieje(string tekst, string wyraz, int licznik)
- {
- int licznik1 = 0;
- bool flag = false;
- for (int i = 0; i < tekst.Length; i++)
- {
- if (tekst[i] == wyraz[0])
- {
- flag = true;
- for (int j = 0; j < wyraz.Length; j++)
- {
- if (i + j >= tekst.Length)
- {
- return false;
- }
- if (tekst[i + j] != wyraz[j])
- {
- flag = false;
- break;
- }
- }
- if (flag)
- {
- licznik1 = licznik1 + 1;
- if (licznik1 == licznik)
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- static void Main(string[] args)
- {
- Console.WriteLine(czyIstnieje("Ala ma ma Ala kota", "ma", 1 ));
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement