Problem 3
In this exercise, your job is to get Karel to create a checkerboard pattern of beepers inside an empty rectangular world, as illustrated in the following before-and-after diagram:
This problem has a nice decomposition structure along with some interesting algorithmic issues. As you think about how you will solve the problem, you should make sure that your solution works with checkerboards that are different in size from the standard 8x8 checkerboard shown in the example. Odd-sized checkerboards are tricky, and you should make sure that your program generates the following pattern in a 5x3 world:
Another special case you need to consider is that of a world which is only one column wide or one row high. The starter folder contains several sample worlds that test these special cases, and you should make sure that your program works for each of them.
**************翻译分割线*************
习题三:
本题中,我们需要操纵卡雷尔使用灰色方块,将空白矩形变成跳棋板,前后效果图如下:
这道题的分步结构非常清晰,算法本身也很有趣。你需要保证卡雷尔能在各种规格的棋盘上
正确执行操作,而不仅是本题中8×8 的标准样式。奇数长宽的棋盘处理起来比较麻烦,你
的程序在5×3 棋盘上应该生成如下图案:
另外一个需要考虑的特殊情况是长或宽为1。本题文件夹下含有各种规格的棋盘,可用来测
试你的程序。请保证你的程序在这些棋盘上均能正确运行。
********************分割线******************************
和Smile 童鞋的作业对比了一下,虽然达到的效果一样,甚至在这道题上,我的源码更简洁写。但总感觉我的源码算法有些土。
他的作业地址:
http://blog.csdn.net/shmming/archive/2010/12/13/6074122.aspx