using System using System Collections Generic using System Linq using

 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static char[] CreateTree(unt n)
{
int m1 = 1, m2 = 1, level = 1, m, k;
char[] z = new char[33000];
z[1] = 'a';
while (level < n)
{
for (k = m1; k <= m2; k++)
{
m = 2 * k;
switch (z[k])
{
case 'a':
{
z[m] = 'b';
z[m + 1] = 'c';
break;
}
case 'b':
{
z[m] = 'c';
z[m + 1] = 'a';
break;
}
case 'c':
{
z[m] = 'a';
z[m + 1] = 'b';
break;
}
}
}
level++;
m1 *= 2;
m2 = m2 * 2 + 1;
}
return z;
}
static void Main(string[] args)
{
}
}
}