Sunday, October 07, 2007

做蛋糕(南瓜派)的算法

家常菜单:
1 and a half cups canned or cooked pumpkin
1 cup brown sugar, firmly packed
half teaspoon salt
2 teaspoon cinnamon
1 teaspoon ginger
2 tablespoons molasses
3 eggs, slightly beaten
12 ounce ccan of evaporated milk
1 unbacked bie crust

Combine pumpkin, sugar, salt, ginger, cinnamon, and molasses. Add eggs and milk and mix thoroughly. Pour into unbaked pie crust and bake in hot oven (425 degrees preheat) for 40 to 45 minutes, or until knife inserted comes out clean.

电脑编程:

(主程序)
MakePumpkinPie (pumpkin, sugar, salt, spices, eggs, milk, crust)
1 PreheatOven (425)
2 filling <- MixFilling (pumpkin, sugar, salt, spices, eggs, milk)
3 pie <- Assemble (crust, filling)
4 While knife inserted does not come out clean
5 Bake (pie)
6 output " Pumpkin pie is completed"
7 return pie

子程序
MixFilling (pumpkin, sugar, salt, spices, eggs, milk)
1 bowl <- Get a bowl from cupboard
2 Put (pumpkin, bowl)
3 Put (sugar, bowl)
4 Put (salt, bowl)
5 Put (spices, bowl)
6 Stir (bowl)
7 Put (eggs, bowl)
8 Put (milk, bowl)
9 Stir (bowl)
10 filling <- Contents of bowl
11 return filling

哎哟,打得累死啦。从我现在正在看的一本书上看到的,笑死我了。斜体的都是变量。

1 comment:

  1. 晕……来踩一脚,睡觉去了……

    ReplyDelete