-
Notifications
You must be signed in to change notification settings - Fork 2
/
CFG4
111 lines (84 loc) · 2.21 KB
/
CFG4
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/// ai bj ck where i<=j && i >= 0 , j >= 0 , c>=0
using System;
class Program
{
int counter = 0;
public char[] _takeIt;
public Program(char[] takeIt)
{
_takeIt = takeIt;
}
public bool checkMe()
{
if (_takeIt[counter] == 'a')
{
counter++;
if (checkMe() == true)
{
if (_takeIt[counter] == 'b')
{
counter++;
return true;
}
}
}
else
return true;
return false;
}
public void validate()
{
if (checkMe() == true)
{
if (_takeIt[counter] == 'b')
B();
else if (_takeIt[counter] == 'c')
Console.Write(" Right ");
else if (_takeIt[counter] == '$')
Console.Write("It's Correct");
}
else
Console.Write("Wrong");
}
public bool B()
{
bool checker = true;
if (checker == true)
{
if (_takeIt[counter] == 'b')
{
counter++;
B();
}
else if (_takeIt[counter] == 'c')
{
C();
checker = false;
}
else if (_takeIt[counter] == '$')
{
Console.Write("Right");
checker = false;
}
}
return true;
}
public void C()
{
if (_takeIt[counter] == 'c')
{
counter++;
C();
}
else if (_takeIt[counter] == '$')
Console.Write("true");
}
static void Main(string[] args)
{
String sender = "aabbcc$";
char[] send = sender.ToCharArray();
Program p = new Program(send);
p.validate();
}
}
/// ai bj ck where i<=j