264 lines
11 KiB
Plaintext
264 lines
11 KiB
Plaintext
%Animal 2 640*480
|
|
title "Russische Bauenmultiplikation"
|
|
author "Michael Scholz, Ulf Gebhardt"
|
|
{
|
|
codegroup "info" at (10, 75) color (0, 0, 0) highlightColor (0, 0, 0) contextColor (0, 0, 0) font SansSerif size 16 italic depth 1
|
|
addCodeLine "Das hier vorgestellte Verfahren eignet sich fuer die Multiplikation zweier ganzer Zahlen." to "info"
|
|
addCodeLine "Die Funktionsweise laesst sich in die folgenden fuenf Schritte gliedern:" to "info"
|
|
addCodeLine "1. Schreibe die beiden zu multiplizierenden Zahlen nebeneinander." to "info" indentation 1
|
|
addCodeLine "2. Die linke Zahl wird halbiert (Reste werden abgerundet), die rechte Zahl wird verdoppelt." to "info" indentation 1
|
|
addCodeLine " Die beiden berechneten Zahlen werden in die darauffolgende Zeile geschrieben." to "info" indentation 2
|
|
addCodeLine "3. Schritt 2 wird solange wiederholt, bis in der linken Spalte eine 1 steht." to "info" indentation 1
|
|
addCodeLine "4. Nun streicht man alle Zeilen, in denen die linke Zahl gerade ist." to "info" indentation 1
|
|
addCodeLine "5. Schlussendlich werden alle uebrigen Zahlen der rechten Spalte addiert." to "info" indentation 1
|
|
text "header" "Russische Bauernmultiplikation" (11, 15) color (0, 0, 0) depth 1 font Serif size 24 italic
|
|
rectangle "headerBackground" offset (-5, -5) from "header" NW offset (5, 5) from "header" SE color (0, 0, 0) depth 2 filled fillColor (128, 128, 128)
|
|
}
|
|
{
|
|
codegroup "sourceCode" at (10, 147) color (0, 0, 0) highlightColor (255, 0, 0) contextColor (0, 0, 0) font SansSerif size 12 depth 1
|
|
addCodeLine "public int russe(int a, int b){" to "sourceCode"
|
|
addCodeLine "if(a == 1){" to "sourceCode" indentation 1
|
|
addCodeLine "return b;" to "sourceCode" indentation 2
|
|
addCodeLine "}" to "sourceCode" indentation 1
|
|
addCodeLine "if(a % 2 == 1){" to "sourceCode" indentation 1
|
|
addCodeLine "return b + russe(a/2, b*2);" to "sourceCode" indentation 2
|
|
addCodeLine "}else{" to "sourceCode" indentation 1
|
|
addCodeLine "return russe(a/2, b*2);" to "sourceCode" indentation 2
|
|
addCodeLine "}" to "sourceCode" indentation 1
|
|
addCodeLine "}" to "sourceCode"
|
|
grid "tb1" (270, 100) lines 7 columns 4 color (0, 0, 0) elementColor (0, 0, 0) fillColor (0, 0, 0) highlightTextColor (0, 0, 0) highlightBackColor (0, 0, 0) depth 1
|
|
setGridValue "tb1[0][0]" "A-Seite"
|
|
setGridValue "tb1[0][1]" "B-Seite"
|
|
setGridValue "tb1[0][2]" "addieren"
|
|
setGridValue "tb1[0][3]" "Summe"
|
|
setGridValue "tb1[1][0]" "27"
|
|
setGridValue "tb1[1][1]" "82"
|
|
setGridValue "tb1[1][2]" ""
|
|
setGridValue "tb1[1][3]" ""
|
|
setGridValue "tb1[2][0]" ""
|
|
setGridValue "tb1[2][1]" ""
|
|
setGridValue "tb1[2][2]" ""
|
|
setGridValue "tb1[2][3]" ""
|
|
setGridValue "tb1[3][0]" ""
|
|
setGridValue "tb1[3][1]" ""
|
|
setGridValue "tb1[3][2]" ""
|
|
setGridValue "tb1[3][3]" ""
|
|
setGridValue "tb1[4][0]" ""
|
|
setGridValue "tb1[4][1]" ""
|
|
setGridValue "tb1[4][2]" ""
|
|
setGridValue "tb1[4][3]" ""
|
|
setGridValue "tb1[5][0]" ""
|
|
setGridValue "tb1[5][1]" ""
|
|
setGridValue "tb1[5][2]" ""
|
|
setGridValue "tb1[5][3]" ""
|
|
setGridValue "tb1[6][0]" ""
|
|
setGridValue "tb1[6][1]" ""
|
|
setGridValue "tb1[6][2]" ""
|
|
setGridValue "tb1[6][3]" "" refresh
|
|
color "tb1" type "fillColor" (255, 255, 255)
|
|
hide "info"
|
|
}
|
|
{
|
|
highlightCode on "sourceCode" line 0 row 0
|
|
unhighlightGridCell "tb1[0][2]" after 0 ticks within 0 ticks
|
|
unhighlightGridCell "tb1[0][3]" after 0 ticks within 0 ticks
|
|
highlightGridCell "tb1[1][0]" after 100 ticks within 100 ticks
|
|
highlightGridCell "tb1[1][1]" after 100 ticks within 100 ticks
|
|
setGridValue "tb1[1][0]" "27" refresh
|
|
setGridValue "tb1[1][1]" "82" refresh
|
|
}
|
|
{
|
|
unhighlightGridCell "tb1[1][0]" after 0 ticks within 0 ticks
|
|
unhighlightGridCell "tb1[1][1]" after 0 ticks within 0 ticks
|
|
unhighlightCode on "sourceCode" line 0 row 0
|
|
highlightCode on "sourceCode" line 1 row 0
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 1 row 0
|
|
highlightCode on "sourceCode" line 4 row 0
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 1 row 0
|
|
unhighlightCode on "sourceCode" line 4 row 0
|
|
highlightCode on "sourceCode" line 5 row 0
|
|
highlightGridCell "tb1[1][2]" after 100 ticks within 100 ticks
|
|
highlightGridCell "tb1[1][3]" after 100 ticks within 100 ticks
|
|
setGridValue "tb1[1][2]" "Ja" refresh
|
|
setGridValue "tb1[1][3]" "82" refresh
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 5 row 0
|
|
highlightCode on "sourceCode" line 0 row 0
|
|
unhighlightGridCell "tb1[1][2]" after 0 ticks within 0 ticks
|
|
unhighlightGridCell "tb1[1][3]" after 0 ticks within 0 ticks
|
|
highlightGridCell "tb1[2][0]" after 100 ticks within 100 ticks
|
|
highlightGridCell "tb1[2][1]" after 100 ticks within 100 ticks
|
|
setGridValue "tb1[2][0]" "13" refresh
|
|
setGridValue "tb1[2][1]" "164" refresh
|
|
}
|
|
{
|
|
unhighlightGridCell "tb1[2][0]" after 0 ticks within 0 ticks
|
|
unhighlightGridCell "tb1[2][1]" after 0 ticks within 0 ticks
|
|
unhighlightCode on "sourceCode" line 0 row 0
|
|
highlightCode on "sourceCode" line 1 row 0
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 1 row 0
|
|
highlightCode on "sourceCode" line 4 row 0
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 1 row 0
|
|
unhighlightCode on "sourceCode" line 4 row 0
|
|
highlightCode on "sourceCode" line 5 row 0
|
|
highlightGridCell "tb1[2][2]" after 100 ticks within 100 ticks
|
|
highlightGridCell "tb1[2][3]" after 100 ticks within 100 ticks
|
|
setGridValue "tb1[2][2]" "Ja" refresh
|
|
setGridValue "tb1[2][3]" "82+164" refresh
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 5 row 0
|
|
highlightCode on "sourceCode" line 0 row 0
|
|
unhighlightGridCell "tb1[2][2]" after 0 ticks within 0 ticks
|
|
unhighlightGridCell "tb1[2][3]" after 0 ticks within 0 ticks
|
|
highlightGridCell "tb1[3][0]" after 100 ticks within 100 ticks
|
|
highlightGridCell "tb1[3][1]" after 100 ticks within 100 ticks
|
|
setGridValue "tb1[3][0]" "6" refresh
|
|
setGridValue "tb1[3][1]" "328" refresh
|
|
}
|
|
{
|
|
unhighlightGridCell "tb1[3][0]" after 0 ticks within 0 ticks
|
|
unhighlightGridCell "tb1[3][1]" after 0 ticks within 0 ticks
|
|
unhighlightCode on "sourceCode" line 0 row 0
|
|
highlightCode on "sourceCode" line 1 row 0
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 1 row 0
|
|
highlightCode on "sourceCode" line 4 row 0
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 1 row 0
|
|
unhighlightCode on "sourceCode" line 4 row 0
|
|
highlightCode on "sourceCode" line 7 row 0
|
|
highlightGridCell "tb1[3][2]" after 100 ticks within 100 ticks
|
|
highlightGridCell "tb1[3][3]" after 100 ticks within 100 ticks
|
|
setGridValue "tb1[3][2]" "Nein" refresh
|
|
setGridValue "tb1[3][3]" "82+164" refresh
|
|
}
|
|
{
|
|
highlightCode on "sourceCode" line 0 row 0
|
|
unhighlightCode on "sourceCode" line 7 row 0
|
|
unhighlightGridCell "tb1[3][2]" after 0 ticks within 0 ticks
|
|
unhighlightGridCell "tb1[3][3]" after 0 ticks within 0 ticks
|
|
highlightGridCell "tb1[4][0]" after 100 ticks within 100 ticks
|
|
highlightGridCell "tb1[4][1]" after 100 ticks within 100 ticks
|
|
setGridValue "tb1[4][0]" "3" refresh
|
|
setGridValue "tb1[4][1]" "656" refresh
|
|
}
|
|
{
|
|
unhighlightGridCell "tb1[4][0]" after 0 ticks within 0 ticks
|
|
unhighlightGridCell "tb1[4][1]" after 0 ticks within 0 ticks
|
|
unhighlightCode on "sourceCode" line 0 row 0
|
|
highlightCode on "sourceCode" line 1 row 0
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 1 row 0
|
|
highlightCode on "sourceCode" line 4 row 0
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 1 row 0
|
|
unhighlightCode on "sourceCode" line 4 row 0
|
|
highlightCode on "sourceCode" line 5 row 0
|
|
highlightGridCell "tb1[4][2]" after 100 ticks within 100 ticks
|
|
highlightGridCell "tb1[4][3]" after 100 ticks within 100 ticks
|
|
setGridValue "tb1[4][2]" "Ja" refresh
|
|
setGridValue "tb1[4][3]" "82+164+656" refresh
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 5 row 0
|
|
highlightCode on "sourceCode" line 0 row 0
|
|
unhighlightGridCell "tb1[4][2]" after 0 ticks within 0 ticks
|
|
unhighlightGridCell "tb1[4][3]" after 0 ticks within 0 ticks
|
|
highlightGridCell "tb1[5][0]" after 100 ticks within 100 ticks
|
|
highlightGridCell "tb1[5][1]" after 100 ticks within 100 ticks
|
|
setGridValue "tb1[5][0]" "1" refresh
|
|
setGridValue "tb1[5][1]" "1312" refresh
|
|
}
|
|
{
|
|
unhighlightGridCell "tb1[5][0]" after 0 ticks within 0 ticks
|
|
unhighlightGridCell "tb1[5][1]" after 0 ticks within 0 ticks
|
|
unhighlightCode on "sourceCode" line 0 row 0
|
|
highlightCode on "sourceCode" line 1 row 0
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 1 row 0
|
|
highlightCode on "sourceCode" line 2 row 0
|
|
highlightGridCell "tb1[5][2]" after 100 ticks within 100 ticks
|
|
highlightGridCell "tb1[5][3]" after 100 ticks within 100 ticks
|
|
setGridValue "tb1[5][2]" "Ja" refresh
|
|
setGridValue "tb1[5][3]" "82+164+656+1312" refresh
|
|
unhighlightGridCell "tb1[5][2]" after 0 ticks within 0 ticks
|
|
unhighlightGridCell "tb1[5][3]" after 0 ticks within 0 ticks
|
|
grid "tb2" offset (0, 10) from "tb1" SW lines 2 columns 1 color (0, 0, 0) elementColor (0, 0, 0) fillColor (0, 0, 0) highlightTextColor (0, 0, 0) highlightBackColor (0, 0, 0) depth 1
|
|
setGridValue "tb2[0][0]" "Rekursion aufloesen:"
|
|
setGridValue "tb2[1][0]" "82+164+656+1312" refresh
|
|
color "tb2" type "fillColor" (255, 255, 255)
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 2 row 0
|
|
unhighlightCode on "sourceCode" line 0 row 0
|
|
}
|
|
{
|
|
highlightCode on "sourceCode" line 5 row 0
|
|
highlightGridCell "tb2[1][0]" after 100 ticks within 100 ticks
|
|
setGridValue "tb2[1][0]" "82+164+1968" refresh after 100 ticks within 100 ticks
|
|
}
|
|
{
|
|
unhighlightGridCell "tb2[1][0]" after 0 ticks within 0 ticks
|
|
unhighlightCode on "sourceCode" line 5 row 0
|
|
}
|
|
{
|
|
highlightCode on "sourceCode" line 7 row 0
|
|
setGridValue "tb2[1][0]" "82+164+1968" refresh after 100 ticks within 100 ticks
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 7 row 0
|
|
}
|
|
{
|
|
highlightCode on "sourceCode" line 5 row 0
|
|
highlightGridCell "tb2[1][0]" after 100 ticks within 100 ticks
|
|
setGridValue "tb2[1][0]" "82+2132" refresh after 100 ticks within 100 ticks
|
|
}
|
|
{
|
|
unhighlightGridCell "tb2[1][0]" after 0 ticks within 0 ticks
|
|
unhighlightCode on "sourceCode" line 5 row 0
|
|
}
|
|
{
|
|
highlightCode on "sourceCode" line 5 row 0
|
|
highlightGridCell "tb2[1][0]" after 100 ticks within 100 ticks
|
|
setGridValue "tb2[1][0]" "2214" refresh after 100 ticks within 100 ticks
|
|
}
|
|
{
|
|
unhighlightCode on "sourceCode" line 5 row 0
|
|
}
|
|
{
|
|
codegroup "statement" at (10, 75) color (0, 0, 0) highlightColor (0, 0, 0) contextColor (0, 0, 0) font SansSerif size 16 italic depth 1
|
|
addCodeLine "Erklaerung:" to "statement"
|
|
addCodeLine "Die Idee des Verfahrens kann man mit Hilfe des Dualsystems verdeutlichen." to "statement"
|
|
addCodeLine "Hierbei wird eine Zahl in ihre Zweierpotenzen zerlegt." to "statement"
|
|
addCodeLine "" to "statement"
|
|
hide "tb1" "tb2" "sourceCode"
|
|
}
|
|
{
|
|
addCodeLine "82 * 27 = 82 * (2^0 + 2^1 + 0 * 2^2 + 2^3 + 2^4 )" to "statement"
|
|
}
|
|
{
|
|
addCodeLine "= 82 * 2^0 + 82 * 2^1 + 82 * 0 + 82 * 2^3 + 82 * 2^4" to "statement" indentation 4
|
|
}
|
|
{
|
|
addCodeLine "= 82 + 164 + 0 + 656 + 1312" to "statement" indentation 4
|
|
}
|
|
{
|
|
addCodeLine "= 2214" to "statement" indentation 4
|
|
}
|
|
|