-
Notifications
You must be signed in to change notification settings - Fork 1
/
valid.bf
95 lines (79 loc) · 2.89 KB
/
valid.bf
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
buffer input input2 string temp0 temp1 temp2 temp3 ans temp4 temp5 print_buffer_1 print_buffer_2 print_buffer_3 input3 exception
input3>>>>>>>>>>>>>>+
input3[
buffer<<<<<<<<<<<<<<, 輸入字元到buffer
input>[-]清空變數
input2>[-]清空變數
string>[-]
temp0>[-]
temp1>[-]
temp2>[-]
temp3>[-]
input3>>>>>>>[-]清空變數
buffer<<<<<<<<<<<<<<[input>+input2>+input3>>>>>>>>>>>>+buffer<<<<<<<<<<<<<<-] 複製buffer至input與input2與input3
string>>>++++++++++ ++++++++++ ++++++++++ ++++++++++ dec:40=ascii"("
string[input<<-string>>-] input減去string 減完後當input為0代表輸入的等於"("
string[-]清空為零
string++++++++++ ++++++++++ ++++++++++ ++++++++++ + dec:41=ascii")"
string[input2<-string>-] input2減去string 減完後當input2為0代表輸入的等於")"
string[-]清空為零
string++++++++++ dec:10=ascii換行
string[input3>>>>>>>>>>>-string<<<<<<<<<<<-] input3減去string 減完後當input3為0代表輸入的等於ascii換行就結束
input<<[temp0>>>+temp1>+input<<<<-]temp0>>>[input<<<+temp0>>>-]+
if input!="(" do notthing
temp1>[
do notthing
temp0<-
temp1>[-]]
else input=="(" ans加1
temp0<[
ans>>>>+
temp0<<<<-]
buffer input input2 string temp0 temp1 temp2 temp3 ans temp4 temp5 print_buffer_1 print_buffer_2 print_buffer_3 input3
temp0[-]
temp1>[-]
input2<<<[temp2>>>>+temp3>+input2<<<<<-]temp2>>>>[input2<<<<+temp2>>>>-]+
if input2!=")" do notthing
temp3>[
do notthing
temp2<-
temp3>[-]]
else input2==")" 確認ans還能不能減少
temp2<[
ans>>[temp0<<<<+temp1>+ans>>>-]temp0<<<<[ans>>>>+temp0<<<<-]+
if ans!=0 減1
temp1>[
ans>>>-
temp0<<<<-
temp1>[-]]
else ans==0 代表不符合 就可以跳開
temp0<[
ans>>>>[-]+
input3>>>>>>[-]
exception>[-]+
temp0<<<<<<<<<<<-]
temp2>>-]
input3>>>>>>>>確認是否要跳開當拿到ascii換行input3為零就會跳開
]
為了漂亮繼續接收字串
exception>[
exception,輸入字元到exception
string<<<<<<<<<<<<[-]清空為零
string++++++++++ dec:10=ascii換行
string[exception>>>>>>>>>>>>-string<<<<<<<<<<<<-] exception減去string 減完後當exception為0代表輸入的等於ascii換行就結束
exception>>>>>>>>>>>>
]
跳開迴圈後根據ans為0就是valid 不為0就是invalid
buffer input input2 string temp0 temp1 temp2 temp3 ans temp4 temp5 print_buffer_1 print_buffer_2 print_buffer_3 input3 exception
temp4<<<<<<[-]
temp5>[-]
ans<<[temp4>+temp5>+ans<<-]temp4>[ans<+temp4>-]+
if ans!=0 輸出invalid
temp5>[
>+[----->+++<]>++.+++++.++++++++.[->+++<]>-.+++++++++++.---.-----.
temp4<<<<-
temp5>[-]]
else ans==0 輸出valid
temp4<[
>>----[-->+++++<]>.[->+++<]>-.+++++++++++.---.-----.
temp4<<<[-]]