update algoanim

This commit is contained in:
M.Scholz 2012-05-07 14:53:55 +02:00
parent 9d80c41091
commit 8486a2309c

View File

@ -3,27 +3,28 @@ title "Russische Bauernmultiplikation"
author "Michael Scholz, Ulf Gebhardt"
{
text "header" "Russische Bauernmultiplikation" at (20, 30) font SansSerif size 24 bold
text "straight" "Die Funktionsweise lässt sich in die folgenden fünf Schritte gliedern:" at (20, 85) font SansSerif size 18
text "straight" "1. Schreibe die beiden zu multiplizierenden Zahlen nebeneinander." at (20, 115) font SansSerif size 18
text "straight" "2. Die linke Zahl wird halbiert (Reste werden abgerundet), die rechte Zahl wird verdoppelt." at (20, 140) font SansSerif size 18
text "straight" "Die beiden berechneten Zahlen werden in die darauffolgende Zeile geschrieben." at (43, 165) font SansSerif size 18
text "straight" "3. Schritt 2 wird solange wiederholt, bis in der linken Spalte eine 1 steht." at (20, 190) font SansSerif size 18
text "straight" "4. Nun streicht man alle Zeilen, in denen die linke Zahl gerade ist." at (20, 215) font SansSerif size 18
text "straight" "5. Schlussendlich werden alle übrigen Zahlen der rechten Spalte addiert." at (20, 240) font SansSerif size 18
text "straight" "Das hier vorgestellte Verfahren eignet sich für die Multiplikation zweier ganzer Zahlen." at (20, 85) font SansSerif size 18 italic
text "straight" "Die Funktionsweise lässt sich in die folgenden fünf Schritte gliedern:" at (20, 150) font SansSerif size 18
text "straight" "1. Schreibe die beiden zu multiplizierenden Zahlen nebeneinander." at (20, 180) font SansSerif size 18
text "straight" "2. Die linke Zahl wird halbiert (Reste werden abgerundet), die rechte Zahl wird verdoppelt." at (20, 205) font SansSerif size 18
text "straight" "Die beiden berechneten Zahlen werden in die darauffolgende Zeile geschrieben." at (43, 230) font SansSerif size 18
text "straight" "3. Schritt 2 wird solange wiederholt, bis in der linken Spalte eine 1 steht." at (20, 255) font SansSerif size 18
text "straight" "4. Nun streicht man alle Zeilen, in denen die linke Zahl gerade ist." at (20, 280) font SansSerif size 18
text "straight" "5. Schlussendlich werden alle übrigen Zahlen der rechten Spalte addiert." at (20, 305) font SansSerif size 18
}
{
hideAll
text "header" "Russische Bauernmultiplikation" at (20, 30) font SansSerif size 24 bold
codeGroup "code" at (10, 147) color black highlightColor red
addCodeLine "public int russe(int a, int b){" to "code"
addCodeLine "\t if(a == 1){" to "code"
addCodeLine "\t \t return b; " to "code"
addCodeLine "\t }" to "code"
addCodeLine "\tif(a % 2 == 1){" to "code"
addCodeLine "\t \t return b + russe(a/2, b*2);" to "code"
addCodeLine "\t }else{" to "code"
addCodeLine "\t \t return russe(a/2, b*2);" to "code"
addCodeLine "\t }" to "code"
addCodeLine "\t \t if(a == 1){" to "code"
addCodeLine "\t \t \t \t return b; " to "code"
addCodeLine "\t \t }" to "code"
addCodeLine "\t \t if(a % 2 == 1){" to "code"
addCodeLine "\t \t \t \t return b + russe(a/2, b*2);" to "code"
addCodeLine "\t \t }else{" to "code"
addCodeLine "\t \t \t \t return russe(a/2, b*2);" to "code"
addCodeLine "\t \t }" to "code"
addCodeLine "}" to "code"
}
{
@ -212,18 +213,20 @@ text "header" "Russische Bauernmultiplikation" at (20, 30) font SansSerif size 2
text "straight" "Erklärung:" at (20, 85) font SansSerif size 18 bold \br
text "straight" "Die Idee des Verfahrens kann man mit Hilfe des Dualsystems verdeutlichen." at (20, 115) font SansSerif size 18
text "straight" "Hierbei wird eine Zahl in ihre Zweierpotenzen zerlegt." at (20, 140) font SansSerif size 18
text "straight" "0" at (204, 153) font SansSerif size 10
text "straight" "1" at (242, 162) font SansSerif size 10
text "straight" "2" at (312, 162) font SansSerif size 10
text "straight" "3" at (350, 162) font SansSerif size 10
text "straight" "4" at (385, 162) font SansSerif size 10
text "straight" "82 * 27 \t = 82 * (2 + 2 + 0 * 2 + 2 + 2 )" at (43, 172) font SansSerif size 18
text "straight" "0" at (200, 180) font SansSerif size 10
text "straight" "1" at (282, 189) font SansSerif size 10
#text "straight" "0" at (204, 153) font SansSerif size 10
text "test" "82 * 27 \t = 82 * (2^0 + 2^1 + 0 * 2^2 + 2^3 + 2^4 )" at (43, 172) font SansSerif size 18
# text "straight" "0" offset (30, 0) from "test" NW font SansSerif size 10
#text "straight" "1" at (242, 162) font SansSerif size 10
#text "straight" "2" at (312, 162) font SansSerif size 10
#text "straight" "3" at (350, 162) font SansSerif size 10
#text "straight" "4" at (385, 162) font SansSerif size 10
text "straight" "3" at (441, 189) font SansSerif size 10
text "straight" "4" at (520, 189) font SansSerif size 10
text "straight" "\t \t \t \t \t \t \t \t \t = 82 * 2 + 82 * 2 + 82 * 0 + 82 * 2 + 82 * 2" at (20, 200) font SansSerif size 18
#text "straight" "0" at (200, 180) font SansSerif size 10
#text "straight" "1" at (282, 189) font SansSerif size 10
#text "straight" "3" at (441, 189) font SansSerif size 10
#text "straight" "4" at (520, 189) font SansSerif size 10
text "straight" "\t \t \t \t \t \t \t \t \t = 82 * 2^0 + 82 * 2^1 + 82 * 0 + 82 * 2^3 + 82 * 2^4" at (20, 200) font SansSerif size 18
text "straight" "\t \t \t \t \t \t \t \t \t = 82 + 164 + 0 + 656 + 1312" at (20, 221) font SansSerif size 18
text "straight" "\t \t \t \t \t \t \t \t \t = 2214" at (20, 246) font SansSerif size 18 bold
}