English
Source / code snippets

Zweithäufigstes and zweitwenigstes element detect

 

p.specht

Kompressionsalgorithmen as Huffman-Codierung require it, the each geringsthäufigste and the second-geringsthäufige element zusammenzufassen. The "Dynamische Huffmancodierung" requires the too with whom häufigsten and zweithäufigsten Elementen... but The must one first time detect:
Window Title "Demo: Zweithäufigstes and Zweitwenigstes element ermitteln"
font 2:randomize:cls rnd(8^8)
' Lineare Häufigkeitsverteilung in k% classes in the area low% To high%
var k%=20 : var low%=10 : var high%=99
declare h%[k%-1]

WhileLoop 0,k%-1

    h%[&Loop]=rnd(high%-low%+1) + low%
    print &Loop,h%[&Loop]

Endwhile

' Häufigstes element
declare max%,maxptr%
max%=0

WhileLoop 0,k%-1

    if h%[&Loop]>max%

        maxptr%=&Loop
        max%=h%[&Loop]

    endif

Endwhile

print
print maxptr%,max%,h%[maxptr%],"  ",
' Zweithäufigstes element
declare max2%,maxptr2%
max2%=0

WhileLoop 0,k%-1

    if &Loop<>maxptr%

        if h%[&Loop]>max2%

            maxptr2%=&Loop
            max2%=h%[&Loop]

        endif

    endif

Endwhile

print maxptr2%,max2%,h%[maxptr2%],"   ",
' Wenigstes element
declare mins%,minptr%
min%=99999

WhileLoop 0,k%-1

    if h%[&Loop]<min%

        minptr%=&Loop
        mins%=h%[&Loop]

    endif

Endwhile

print minptr%,mins%,h%[minptr%],"   ",
' Zweitwenigstes element
declare mins2%,minptr2%
min2%=99999

WhileLoop 0,k%-1

    if &Loop<>minptr%

        if h%[&Loop]<min2%

            minptr2%=&Loop
            mins2%=h%[&Loop]

        endif

    endif

Endwhile

print minptr2%,mins2%,h%[minptr2%]
locate maxptr%+1,10:print "< Maximum"
locate maxptr2%+1,10:print "< Next-to-Max"
locate minptr%+1,10:print "< Minimum"
locate minptr2%+1,10:print "< Next-to-Min"
Waitinput
 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
04/25/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

679 Views

Untitledvor 0 min.
N.Art07/21/22
Ernst07/21/21
Glubbfan06/19/21
Uwe ''Pascal'' Niemeier06/13/21
More...

Themeninformationen

this Topic has 1 subscriber:

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