How to think like a Computer Scientist: 课后习题第七章 11-13
来源:互联网 发布:朝鲜高仿人民币 淘宝 编辑:程序博客网 时间:2024/05/03 10:56
#-------------------------------------------------------------------------------# Name: module1# Purpose:## Author: penglaixy## Created: 27/07/2013# Copyright: (c) penglaixy 2013# Licence: <your licence>#-------------------------------------------------------------------------------import sysimport turtleimport timedef adjust_window(t): t.penup() t.right(90) t.forward(100) t.left(90) t.pendown()def test(did_pass): ''' print the result of a test ''' linenum = sys._getframe(1).f_lineno if did_pass: msg = 'Test at line {0} ok'.format(linenum) else: msg = 'Test at line {0} failed'.format(linenum) print msgdef draw_shape(angle_list): tess = turtle.Turtle() wn = turtle.Screen() adjust_window(tess) wn.bgcolor('lightgreen') tess.color('navy blue') tess.pensize(10) for (angle, step) in angle_list: tess.left(angle) tess.forward(step) time.sleep(8) wn.bye()def draw_drunk_priate(): angle_list = [(160, 200),(-43, 100), (270, 80), (-43, 120)] draw_shape(angle_list)def draw_house(): angle_list = [(90,150),(30,150),(120,150),(120,150),(225,216),(225,150),(225,216),(225,150)] draw_shape(angle_list)def test_suite(): ''' Run the suite of tests for code in this module ''' draw_drunk_priate() #draw_house()def main(): test_suite()if __name__ == '__main__': main()
下面这段话是从维基百科中搜索到的:
http://en.wikipedia.org/wiki/Eulian_path
In graph theory, an Eulerian trail (or Eulerian path) is a trail in a graph which visits every edge exactly once. Similarly, an Eulerian circuit or Eulerian cycleis an Eulerian trail which starts and ends on the same vertex.
Euler proved that a necessary condition for the existence of Eulerian circuits is that all vertices in the graph have an even degree,(每个顶点都有偶数个角度) and stated without proof that connected graphs with all vertices of even degree have an Eulerian circuit.
The term Eulerian graph has two common meanings in graph theory. One meaning is a graph with an Eulerian circuit, and the other is a graph with every vertex of even degree. These definitions coincide for connected graphs.
For the existence of Eulerian trails it is necessary that no more than two vertices have an odd degree(有奇数个角度的顶点个数不大于两个); this means the K?nigsberg graph is not Eulerian. If there are no vertices of odd degree, all Eulerian trails are circuits. If there are exactly two vertices of odd degree(我们画的房子的最底下的两个顶点的角度个数都是3,说的就是这种情况), all Eulerian trails start at one of them and end at the other. A graph that has an Eulerian trail but not an Eulerian circuit is called semi-Eulerian.
第13题,除了第三个第四个图形不能画,其他的都可以,我没有试过,只是根据角度判断的,有兴趣的自己试着画吧
- How to think like a Computer Scientist: 课后习题第七章 11-13
- How to think like a Computer Scientist: 课后习题第七章 1-10
- How to think like a Computer Scientist: 课后习题第七章 14-17
- How to think like a Computer Scientist: 课后习题第六章 13-19
- How to think like a Computer Scientist: 课后习题第十一章 5-11
- How to think like a Computer Scientist: 课后习题第十八章9-11
- How to think like a Computer Scientist: 课后习题第三章 12题
- How to think like a computer scientist: 第四章 课后习题 1
- How to think like a Computer Scientist: 课后习题第四章 2题
- How to think like a computer scientist: 第五章 课后习题 9
- How to think like a computer scientist: 第四章 课后习题 5
- How to think like a Computer Scientist: 课后习题第四章 10
- How to think like a Computer Scientist: 课后习题第六章 1-5
- How to think like a Computer Scientist: 课后习题第六章 6-12
- How to think like a Computer Scientist: 课后习题第八章
- How to think like a Computer Scientist: 课后习题第九章 第2题
- How to think like a Computer Scientist: 课后习题第九章 第3题
- How to think like a Computer Scientist: 课后习题第九章 第4题
- ArraList,LinkList,List,Vector的区别
- QThread 与 QObject的关系
- 安智
- Java多线程之Callable接口的实现
- eclipse CDT 运行时弹出运行结果的console,而非...[C/C++ Application] gdb(traces)窗口的解决方法
- How to think like a Computer Scientist: 课后习题第七章 11-13
- 虚拟文件系统
- LeetCode-Length of Last Word
- hdu 1198 Farm Irrigation
- Android-Native-Server 启动和注册详细分析
- 通过“CreateProcess”创建新的“进程”
- C++编写ATM(1)
- Android手势源码浅析----手势识别
- 数据库核心の增删改查