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 Regular
- {
- class Program
- {
- static int secondtry(string first)
- {
- int i = 0;
- goto GroupFirst;
- return -2;
- GroupFirst:
- if ((first[i] == 'a') & (i < first.Length - 1))
- {
- i++;
- Brepeat:
- if ((first[i] == 'b') & (i < first.Length - 1))
- {
- i++;
- goto Brepeat;
- }
- else if ((first[i] == 'c') & (i < first.Length - 1))
- {
- i++;
- if ((first[i] == 'a') & (i < first.Length - 1))
- goto GroupFirst;
- }
- if ((first[i] == 'd') & (i < first.Length - 1))
- {
- i++;
- Bplus:
- if ((first[i] == 'b') & (i < first.Length - 1))
- {
- i++;
- goto Bplus;
- }
- else if (first[i + 1] == 'b')
- {
- return -1;
- }
- else
- return i + 1;
- }
- else
- return i;
- }
- else
- return i;
- }
- //(ab*c)+db+
- static int myregular(string first)
- {
- if(first.Length == 0)
- {
- return -2;
- }
- int i = 0;
- bool flag = false;
- Group:
- if ((first[i] == 'a' | !flag) & (i < first.Length - 1))
- {
- i++;
- MultiB:
- if(first[i] == 'b' & (i < first.Length - 1))
- {
- i++;
- goto MultiB;
- }
- else if(first[i] == 'c' & (i < first.Length - 1))
- {
- i++;
- flag = true;
- goto Group;
- }
- else
- {
- return i;
- }
- }
- else if(first[i] == 'd' & (i < first.Length - 1))
- {
- i++;
- EndB:
- if (first[i] == 'b' & (i < first.Length - 1))
- {
- i++;
- goto EndB;
- }
- else
- {
- if (first[i] == 'b')
- return -1;
- else
- return i;
- }
- }
- else
- {
- if (first[i] == 'b')
- return -1;
- else
- return i;
- }
- }
- static void Main(string[] args)
- {
- string test = "abbccccc";
- Console.WriteLine(test);
- int number = secondtry(test);
- if (number == -1)
- Console.WriteLine("success");
- else if (number == -2)
- Console.WriteLine("Wrong line");
- else
- {
- number++;
- Console.WriteLine("Unsucces in " + number + " symbol.");
- }
- Console.Read();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement