forked from Daniyal07/automata_cfg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CFG7
66 lines (52 loc) · 1.11 KB
/
CFG7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//ai bj ck where i = j + k && j >= 0 , k >= 0
using System;
class Program
{
//aaabbc
// ai bj ck where i = j + k && j >=0 , k >= 0
char[] takeInput;
int counter = 0;
public Program(char[] takeInput)
{
this.takeInput = takeInput;
}
public bool S()
{
if (takeInput[counter] == 'a')
{
counter++;
if (S() == true)
{
if (takeInput[counter] == 'b' | takeInput[counter] == 'c')
{
counter++;
return true;
}
}
}
else
{
return true;
}
return false;
}
public void validate()
{
if (S() == true)
{
if (takeInput[counter] == '$')
{
Console.WriteLine("True");
}
else
Console.WriteLine("False");
}
else
Console.WriteLine("False");
}
static void Main()
{
Program P = new Program("aaabcc$".ToCharArray());
P.validate();
}
}