English
Source / code snippets

Klammer-Ausgewogenheitstest Quick´n Dirty

 

p.specht


Window Title "Klammer-Ausgewogenheitstest"
cls
declare u&,d&, r$
r$="latitude! (* (/ (+ lat! (* (- (+ 1 (* e2cuadrada! (math_pow(cos lat!)2)) ) (* (/ 3.0 2.0) e2cuadrada! (sin lat!) (cos lat!) (- tao! lat!))) (- tao! lat!))) Math_PI) 180.0)"

whileloop len(r$)

    case mid$(r$,&Loop,1)="(":inc u&
    case mid$(r$,&Loop,1)=")":inc d&

endwhile

print "( ... ";u&
print ") ... ";d&

if d&<>u&

    print " not well-balanced!"

else

    print " OK."

endif

waitinput
 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
07/04/21  
 




Sven
Bader
thanks for Presentation! I have it yet verfeinert, clinging in Zeichenketten and Kommentaren go ignoring. as by-product go so too yet apertured Zeichenketten as error recognized.
Proc BracketBalance

    Parameters line$
    Declare c$, u&, d&, st%

    WhileLoop len(line$)

        c$ = mid$(line$,&Loop,1)
        case (c$ = "\q") :  st% = If(st% = 0, 1, 0)

        If (st% = 0)'only unless in a Zeichenkette

            If (c$ = "'") AND (st% = 0)'with comment is Schluss

                break

            EndIf

            case (c$ = "(") : inc u&
            case (c$ = ")") : inc d&

        EndIf

    EndWhile

    '0 = ok, 1 = clinging unausgewogen, 2 = Zeichenkette not gschlossen, 3 = both broken
    return (if(u& <> d&,1,0) + if(st% = 1, 2, 0))

ENDPROC

declare s1$, s2$, s3$, s4$
s1$ = "Das is a (\qguter\q) Test! 'with comment :-)"
s2$ = "Das is a (\qguter) Test! 'with comment :-)"
s3$ = "Das is a (\qguter\q Test! 'with comment :-)"
s4$ = "Das is a (guter) \qTest! 'with comment :-)"
print BracketBalance(s1$) + " " + s1$'0 = ok
print BracketBalance(s2$) + " " + s2$'3 = both broken (Klammer only because second ausversehen in Zeichenkette)
print BracketBalance(s3$) + " " + s3$'1 = clinging unausgewogen
print BracketBalance(s4$) + " " + s4$'2 = Zeichenkette not gschlossen
waitinput
end
 
08/18/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.844 Views

Untitledvor 0 min.
ecki07/30/23
Rschnett08/06/22
p.specht11/18/21
Peter Max Müller11/18/21
More...

Themeninformationen

this Topic has 2 subscriber:

Sven Bader (1x)
p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie