斯坦福大学开放课程——编程方法 作业1-3 (附作业中文翻译及源码)【放置黑白棋盘】

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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值