-
Notifications
You must be signed in to change notification settings - Fork 0
/
turing1.cpp
91 lines (88 loc) · 1.3 KB
/
turing1.cpp
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
#include<iostream>
#include<cstring>
using namespace std;
char str[25];
int n;
class turing
{
public:
void push(char x,char y,int i)
{
str[i]=y;
}
};
int main()
{
int i=0,j=0;
gets(str);
turing st;
n=strlen(str);
while (str[i]=='b')
{
st.push('b','b',i);
i++;
}
while (str[i]=='1'||str[i]=='0')
{
if(str[i]=='1')
st.push('1','X',i);
if(str[i]=='0')
st.push('0','Y',i);
i++;
}
i--;/*
while (str[i]=='X'||str[i]=='Y')
{
if(str[i]=='X')
st.push('X','X',i);
if(str[i]=='Y')
st.push('Y','Y',i);
i--;
}
i++;*/
while(str[i]!='b')
{
if(str[i]=='X')
{
st.push('X','1',i++);
while (str[i]=='1'||str[i]=='0')
{
if(str[i]=='1')
st.push('1','1',i);
if(str[i]=='0')
st.push('0','0',i);
i++;
}
if(str[i]=='b')
{
st.push('b','1',i--);
}
}
if(str[i]=='Y')
{
st.push('Y','0',i++);
while (str[i]=='1'||str[i]=='0')
{
if(str[i]=='1')
st.push('1','1',i);
if(str[i]=='0')
st.push('0','0',i);
i++;
}
if(str[i]=='b')
{
st.push('b','0',i--);
}
}
while (str[i]=='1'||str[i]=='0')
{
if(str[i]=='1')
st.push('1','1',i);
if(str[i]=='0')
st.push('0','0',i);
i--;
}
}
puts(str);
return 0;
}