Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace k3._2
- {
- class Program
- {
- static bool CzyLitera(char a)
- {
- if (a>='A'&&a<='Z'||a>='a'&&a<='z')
- {
- return true;
- }
- return false;
- }
- static string Zamienmale(string a)
- {
- string tmp = "";
- char c;
- for (int i = 0; i < a.Length; i++)
- {
- if (CzyLitera(a[i]))
- {
- if (a[i] >= 'a' && a[i] <= 'z')
- {
- tmp += a[i];
- }
- if (a[i] >= 'A' && a[i] <= 'Z')
- {
- c = (char)(a[i] + ('a' - 'A'));
- tmp += c;
- }
- }
- else
- {
- tmp += a[i];
- }
- }
- return tmp;
- }
- static int IleWyrazow(string tekst, char a, char b, char c)
- {
- string d = Zamienmale(tekst);
- string tmp = "";
- int liczbasekwencji = 0;
- int liczbawyrazow = 0;
- for (int i = 0; i < d.Length; i++)
- {
- if (CzyLitera(d[i])&&i<d.Length)
- {
- while (i < d.Length&&CzyLitera(d[i]))
- {
- tmp += d[i];
- i++;
- }
- for (int j = 0; j < tmp.Length-2; j++)
- {
- if (tmp[j]=='a'&&tmp[j+1]!='b'&&tmp[j+2]=='c')
- {
- liczbasekwencji++;
- }
- }
- tmp = "";
- if (liczbasekwencji == 1)
- {
- liczbawyrazow++;
- }
- }
- }
- return liczbawyrazow;
- }
- static void Main(string[] args)
- {
- string b = "katar";
- Console.WriteLine(IleWyrazow(b,'a','l','a'));
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement