Yazılım düşünmeyi öğrenmek

Aşağıda ki codu ArraySort.nsd olarak notepad ile (veya linux te vi/nano/gedit…) kaydederseniz programa atıp çalıştırabilirsiniz. Basit bir dizi sıralama algoritmasının çalışması. <?xml version="1.0" encoding="UTF-8"?> <root xmlns:nsd="https://structorizer.fisch.lu" version="3.28-09" preRepeat="until " postFor="to" preReturn="return" postForIn="in" preWhile="while " output="OUTPUT" input="INPUT" preFor="for" preExit="exit" preLeave="leave" ignoreCase="true" preForIn="foreach" stepFor="by" author="can" created="2018-10-07" changedby="can" changed="2018-10-07" origin="Structorizer 3.28-09" text="&#34;ArraySort&#34;" comment="&#34;&#34;" color="ffffff" type="program" style="nice"> <children> <instruction text="&#34;dizi &#60;- {2,5,-2,6,-3,8,0,-7,-9,4 }&#34;" comment="&#34;&#34;" color="ffffff" rotated="0" disabled="0"></instruction> <instruction text="&#34;sortedArray &#60;- {0,0,0,0,0,0,0,0,0,0}&#34;" comment="&#34;&#34;" color="ffffff" rotated="0" disabled="0"></instruction> <instruction text="&#34;n1 &#60;- length(dizi)&#34;" comment="&#34;&#34;" color="ffffff" rotated="0" disabled="0"></instruction> <instruction text="&#34;n &#60;- n1-1&#34;" comment="&#34;&#34;" color="ffffff" rotated="0" disabled="0"></instruction> <instruction text="&#34;max &#60;- -999&#34;" comment="&#34;&#34;" color="ffffff" rotated="0" disabled="0"></instruction> <instruction text="&#34;indexHolder &#60;- 0&#34;" comment="&#34;&#34;" color="ffffff" rotated="0" disabled="0"></instruction> <for text="&#34;for k &#60;- 0 to n&#34;" comment="&#34;&#34;" counterVar="k" startValue="0" endValue="n" stepConst="1" style="COUNTER" color="ffffff" disabled="0"> <qFor> <for text="&#34;for i &#60;- 0 to n&#34;" comment="&#34;&#34;" counterVar="i" startValue="0" endValue="n" stepConst="1" style="COUNTER" color="ffffff" disabled="0"> <qFor> <alternative text="&#34;(dizi[i] &#62; max)&#34;" comment="&#34;&#34;" color="ffffff" disabled="0"> <qTrue> <instruction text="&#34;max:= dizi[i]&#34;" comment="&#34;&#34;" color="ffffff" rotated="0" disabled="0"></instruction> <instruction text="&#34;indexHolder := i&#34;" comment="&#34;&#34;" color="ffffff" rotated="0" disabled="0"></instruction> </qTrue> <qFalse color="ffffff"> </qFalse> </alternative> </qFor> </for> <instruction text="&#34;sortedArray[k] :=dizi[indexHolder]&#34;" comment="&#34;&#34;" color="ffffff" rotated="0" disabled="0"></instruction> <instruction text="&#34;dizi[indexHolder] := -999&#34;" comment="&#34;&#34;" color="ffffff" rotated="0" disabled="0"></instruction> <instruction text="&#34;max := -999&#34;" comment="&#34;&#34;" color="ffffff" rotated="0" disabled="0"></instruction> </qFor> </for> <for text="&#34;for j &#60;- 0 to n&#34;" comment="&#34;&#34;" counterVar="j" startValue="0" endValue="n" stepConst="1" style="COUNTER" color="ffffff" disabled="0"> <qFor> <instruction text="&#34;Output sortedArray[j]&#34;" comment="&#34;&#34;" color="ffffff" rotated="0" disabled="0"></instruction> </qFor> </for> </children> </root>  ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *