Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Regular
  8. {
  9.     class Program
  10.     {
  11.  
  12.         static int secondtry(string first)
  13.         {
  14.             int i = 0;
  15.             goto GroupFirst;
  16.             return -2;
  17.  
  18.         GroupFirst:
  19.             if ((first[i] == 'a') & (i < first.Length - 1))
  20.             {
  21.                 i++;
  22.             Brepeat:
  23.                 if ((first[i] == 'b') & (i < first.Length - 1))
  24.                 {
  25.                     i++;
  26.                     goto Brepeat;
  27.                 }
  28.                 else if ((first[i] == 'c') & (i < first.Length - 1))
  29.                 {
  30.                     i++;
  31.                     if ((first[i] == 'a') & (i < first.Length - 1))
  32.                         goto GroupFirst;
  33.                 }
  34.                 if ((first[i] == 'd') & (i < first.Length - 1))
  35.                 {
  36.                     i++;
  37.                 Bplus:
  38.                     if ((first[i] == 'b') & (i < first.Length - 1))
  39.                     {
  40.                         i++;
  41.                         goto Bplus;
  42.                     }
  43.                     else if (first[i + 1] == 'b')
  44.                     {
  45.                         return -1;
  46.                     }
  47.                     else
  48.                         return i + 1;
  49.                 }
  50.                 else
  51.                     return i;
  52.             }
  53.             else
  54.                 return i;
  55.         }
  56.  
  57.         //(ab*c)+db+
  58.         static int myregular(string first)
  59.         {
  60.             if(first.Length == 0)
  61.             {
  62.                 return -2;
  63.             }
  64.             int i = 0;
  65.             bool flag = false;
  66.             Group:
  67.                 if ((first[i] == 'a' | !flag) & (i < first.Length - 1))
  68.                 {
  69.                     i++;
  70.                     MultiB:
  71.                     if(first[i] == 'b' & (i < first.Length - 1))
  72.                     {
  73.                         i++;
  74.                         goto MultiB;
  75.                     }
  76.                     else if(first[i] == 'c' & (i < first.Length - 1))
  77.                     {
  78.                         i++;
  79.                         flag = true;
  80.                         goto Group;
  81.                     }
  82.                     else
  83.                     {
  84.                         return i;
  85.                     }
  86.                 }
  87.                 else if(first[i] == 'd' & (i < first.Length - 1))
  88.                 {
  89.                     i++;
  90.                     EndB:
  91.                     if (first[i] == 'b' & (i < first.Length - 1))
  92.                     {
  93.                         i++;
  94.                         goto EndB;
  95.                     }
  96.                     else
  97.                     {
  98.                         if (first[i] == 'b')
  99.                             return -1;
  100.                         else
  101.                             return i;
  102.                     }
  103.                 }
  104.                 else
  105.                 {
  106.                     if (first[i] == 'b')
  107.                         return -1;
  108.                     else
  109.                         return i;
  110.                 }
  111.         }
  112.  
  113.  
  114.         static void Main(string[] args)
  115.         {
  116.             string test = "abbccccc";
  117.             Console.WriteLine(test);
  118.             int number = secondtry(test);
  119.             if (number == -1)
  120.                 Console.WriteLine("success");
  121.             else if (number == -2)
  122.                 Console.WriteLine("Wrong line");
  123.             else
  124.             {
  125.                 number++;
  126.                 Console.WriteLine("Unsucces in " + number + " symbol.");
  127.             }
  128.             Console.Read();
  129.         }
  130.     }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement