Balanced brackets: Difference between revisions
Content added Content deleted
imported>Arakov |
imported>Thebeez (Added uBasic/4tH version) |
||
Line 1,707: | Line 1,707: | ||
NEXT i |
NEXT i |
||
END</syntaxhighlight> |
END</syntaxhighlight> |
||
==={{header|uBasic/4tH}}=== |
|||
<syntaxhighlight lang="qbasic">@(0) := "[]][][][[]" |
|||
@(1) := "[[[][]]]" |
|||
@(2) := "[[[]][[[][[][]]]]]" |
|||
@(3) := "][][]][[" |
|||
@(4) := "[][][]" |
|||
@(5) := "[][]][]][[]]][[[" |
|||
@(6) := "]][[[[]]]][]]][[[[" |
|||
@(7) := "[[][[[]]][]]" |
|||
@(8) := "[]][][][[[]]" |
|||
@(9) := "][]][[" |
|||
For x = 0 To 9 |
|||
Print Using "(_#)";x,Show (@(x));Tab (30); |
|||
Do While (Set (a, Find(@(x), "[]")) < 0) = 0 |
|||
@(x) = Join (Clip (@(x), Len (@(x)) - a), Chop (@(x), a + 2)) |
|||
Loop |
|||
Print "is";Show (Iif (Len (@(x))," not "," "));"balanced" |
|||
Next</syntaxhighlight> |
|||
{{Out}} |
|||
<pre>( 0) []][][][[] is not balanced |
|||
( 1) [[[][]]] is balanced |
|||
( 2) [[[]][[[][[][]]]]] is balanced |
|||
( 3) ][][]][[ is not balanced |
|||
( 4) [][][] is balanced |
|||
( 5) [][]][]][[]]][[[ is not balanced |
|||
( 6) ]][[[[]]]][]]][[[[ is not balanced |
|||
( 7) [[][[[]]][]] is balanced |
|||
( 8) []][][][[[]] is not balanced |
|||
( 9) ][]][[ is not balanced |
|||
0 OK, 0:472 </pre> |
|||
=={{header|Batch File}}== |
=={{header|Batch File}}== |