Homework 3: Higher-Order Functions, Self Reference, Recursion, Tree Recursion

Q1: Compose

编写一个高阶函数composer,它返回两个函数funcfunc_adder。 func是一个单参数函数,它应用到目前为止已经组合的所有函数。这些函数将首先应用最新的函数(参见doctests和示例)。 func_adder用于向我们的组合添加更多函数,当调用另一个函数g时,func_adder应该返回一个新的func和一个新的func_adder

如果没有参数传入composer,则返回的func是恒等函数。

举例来说:

>>> add_one = lambda x: x + 1
>>> square = lambda x: x * x
>>> times_two = lambda x: x + x

>>> f1, func_adder = composer()
>>> f1(1)
1

>>> f2, func_adder = func_adder(add_one)
>>> f2(1)
2   # 1 + 1

>>> f3, func_adder = func_adder(square)
>>> f3(3)
10  # 1 + (3**2)

>>> f4, func_adder = func_adder(times_two)
>>> f4(3)
37  # 1 + ((2 * 3) **2)

提示:你的func_adder应该返回两个参数func和 func_adder.

我们知道什么函数返回funcfunc_adder

(这个提示真的神来之笔:由于compose返回

func

func_adder这两个函数

所以func_adder应该是以新func为形参的compose函数

(func    =         lambda x:func(g(x))       

g(x)作为原函数的参数x        逐级嵌套 )如图:

def composer(func=lambda x: x):
    """
    Returns two functions -
    one holding the composed function so far, and another
    that can create further composed problems.
    >>> add_one = lambda x: x + 1
    >>> mul_two = lambda x: x * 2
    >>> f, func_adder = composer()
    >>> f1, func_adder = func_adder(add_one)
    >>> f1(3)
    4
    >>> f2, func_adder = func_adder(mul_two)
    >>> f2(3) # should be 1 + (2*3) = 7
    7
    >>> f3, func_adder = func_adder(add_one)
    >>> f3(3) # should be 1 + (2 * (3 + 1)) = 9
    9
    """
    def func_adder(g):
        "*** YOUR CODE HERE ***"
        return  composer(lambda x:func(g(x)))

    return func, func_adder

pass:

PS D:\pycharm\python document\CS61A class homework\hw03> python3 ok -q composer
=====================================================================
Assignment: Homework 3
OK, version v1.18.1
=====================================================================

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests

---------------------------------------------------------------------
Test summary
    1 test cases passed! No cases failed.

Q4: Count change

Once the machines take over, the denomination of every coin will be a power of two: 1-cent, 2-cent, 4-cent, 8-cent, 16-cent, etc. There will be no limit to how much a coin can be worth.

Given a positive integer total, a set of coins makes change for total if the sum of the values of the coins is total. For example, the following sets make change for 7:

  • 7 1-cent coins
  • 5 1-cent, 1 2-cent coins
  • 3 1-cent, 2 2-cent coins
  • 3 1-cent, 1 4-cent coins
  • 1 1-cent, 3 2-cent coins
  • 1 1-cent, 1 2-cent, 1 4-cent coins

Thus, there are 6 ways to make change for 7. Write a recursive function count_change that takes a positive integer total and returns the number of ways to make change for total using these coins of the future.

Hint: Refer the implementation of count_partitions for an example of how to count the ways to sum up to a total with smaller parts. If you need to keep track of more than one value across recursive calls, consider writing a helper function.

分析:作者把此题核心分为两个函数

divide函数:

作用:

求 对于total 满足1------小于total的最大2的倍数 面值美分  的排列种类

核心:

将一种情况分为两种情况即:

当前有最大数的排列数量        和        无当前最大数的数量

举个例子如图(函数实现过程):

max1:

求的是 小于total的最大2的倍数

def divide(total,num):
    if num==1:
        return 1
    if total<num:
        return divide(total,num/2)
    return divide(total-num,num)+divide(total,num/2)

def max1(total):
    if total<=1:
        return 1
    if total>0:
        return max1(total//2)*2
def count_change(total):
    """Return the number of ways to make change for total.

    >>> count_change(7)
    6
    >>> count_change(10)
    14
    >>> count_change(20)
    60
    >>> count_change(100)
    9828
    >>> from construct_check import check
    >>> # ban iteration
    >>> check(HW_SOURCE_FILE, 'count_change', ['While', 'For'])
    True
    """
    "*** YOUR CODE HERE ***"
    if total==1:
        return 1
    return divide(total,max1(total))

pass结果:

PS D:\pycharm\python document\CS61A class homework\hw03> python3 ok -q count_change
=====================================================================
Assignment: Homework 3
OK, version v1.18.1
=====================================================================

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests

---------------------------------------------------------------------
Test summary
    1 test cases passed! No cases failed.

Q5: Towers of Hanoi

一个经典的难题称为塔的河内是一个游戏,包括三个 杆和许多不同尺寸的圆盘,圆盘可以在任何杆上滑动。 这个谜题从n磁盘开始,磁盘按照大小的升序整齐地堆叠在一起, start棒,顶部最小,形成圆锥形。

拼图的目的是将整个堆叠移动到end杆, 遵守以下规则:

  • 一次只能移动一个磁盘。
  • 每次移动包括从其中一根杆上取下顶部(最小)的圆盘, 把它滑到另一个杆上,在其他可能已经被 存在于该杆上。
  • 不能将磁盘放在较小磁盘的顶部。

完成move_stack的定义,它将打印出执行以下操作所需的步骤: 将n盘从start棒移动到end棒,不违反 规则提供的print_move函数将打印出移动 从给定的origin到给定的destination的单个磁盘。

提示:在一张纸上画出几个带有各种n的游戏,并尝试 找到一个适用于任何n的磁盘运动模式。在你的解决方案中, 当你需要移动任何数量的 小于n的圆盘从一个棒到另一个棒。如果你需要更多帮助, 以下提示。

 分析:

核心:拆分思想(动态规划dp)

对于n个盘子需要从起点到终点的问题可以转化为

1.将n个盘子需要从起点到非起点或终点,

2.第n个盘子从起点到终点

3.再将n-1盘子放到终点的过程

(1)其中对于n==2的情况(即递归终点)需要模拟出相应过程

注意:n==1需要额外说明

如图所示:

def print_move(origin, destination):
    """Print instructions to move a disk."""
    print("Move the top disk from rod", origin, "to rod", destination)


def move_stack(n, start, end):
    """Print the moves required to move n disks on the start pole to the end
    pole without violating the rules of Towers of Hanoi.

    n -- number of disks
    start -- a pole position, either 1, 2, or 3
    end -- a pole position, either 1, 2, or 3

    There are exactly three poles, and start and end must be different. Assume
    that the start pole has at least n disks of increasing size, and the end
    pole is either empty or has a top disk larger than the top n start disks.

    >>> move_stack(1, 1, 3)
    Move the top disk from rod 1 to rod 3
    >>> move_stack(2, 1, 3)
    Move the top disk from rod 1 to rod 2
    Move the top disk from rod 1 to rod 3
    Move the top disk from rod 2 to rod 3
    >>> move_stack(3, 1, 3)
    Move the top disk from rod 1 to rod 3
    Move the top disk from rod 1 to rod 2
    Move the top disk from rod 3 to rod 2
    Move the top disk from rod 1 to rod 3
    Move the top disk from rod 2 to rod 1
    Move the top disk from rod 2 to rod 3
    Move the top disk from rod 1 to rod 3
    """
    assert 1 <= start <= 3 and 1 <= end <= 3 and start != end, "Bad start/end"
    "*** YOUR CODE HERE ***"
    n_s=0
    if 1!=start and 1!=end:
        n_s=1
    if 2!=start and 2!=end:
        n_s=2
    if 3!=start and 3!=end:
        n_s=3
    if n==1:
        print_move(start,end)
        return
    if n==2:
        print_move(start,n_s)
        print_move(start,end)
        print_move(n_s,end)
        return
    move_stack(n-1,start,n_s)
    print_move(start,end)
    move_stack(n-1,n_s,end)

pass情况:

PS D:\pycharm\python document\CS61A class homework\hw03> python3 ok -q move_stack
=====================================================================
Assignment: Homework 3
OK, version v1.18.1
=====================================================================

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests

---------------------------------------------------------------------
Test summary
    1 test cases passed! No cases failed.

Q6: Anonymous factorial

The recursive factorial function can be written as a single expression by using a conditional expression.

>>> fact = lambda n: 1 if n == 1 else mul(n, fact(sub(n, 1)))
>>> fact(5)
120

However, this implementation relies on the fact (no pun intended) that fact has a name, to which we refer in the body of fact. To write a recursive function, we have always given it a name using a def or assignment statement so that we can refer to the function within its own body. In this question, your job is to define fact recursively without giving it a name!

Write an expression that computes n factorial using only call expressions, conditional expressions, and lambda expressions (no assignment or def statements). Note in particular that you are not allowed to use make_anonymous_factorial in your return expression. The sub and mul functions from the operator module are the only built-in functions required to solve this problem:

from operator import sub, mul

def make_anonymous_factorial():
    """Return the value of an expression that computes factorial.

    >>> make_anonymous_factorial()(5)
    120
    >>> from construct_check import check
    >>> # ban any assignments or recursion
    >>> check(HW_SOURCE_FILE, 'make_anonymous_factorial', ['Assign', 'AugAssign', 'FunctionDef', 'Recursion'])
    True
    """
    return lambda n : (lambda x, function : 1 if x == 1 else x * function(x - 1, function))(n, lambda x, function : 1 if x == 1 else x * function(x - 1, function))

分析:

 from operator import sub, mul
 ​
 def make_anonymous_factorial():
     def function(x, function):
         if(x == 1):
             return 1
         else:
             return function(x - 1, function) * x
     return lambda n : function(n, function)

 我采取了High-order Function的方法,

定义一个将自身作为参数的函数

从更深层次的角度来讲,

这不过是将“函数”的Abstraction程度降低了一层,将 “函数寻址”这一行为显式地实现了

function()用lambda表达出来即:

lambda x, function : 1 if x == 1 else x * function(x - 1, function)

合并即以下答案:

1.lambda x:

函数体:

( lambda x,function:function(x-1,function)*x if x>0 else 1)

参数:

(x,lambda x,function:function(x-1,function)*x if x>0 else 1)

另外一种形式:

2.

lambda x:

函数体:

(lambda x,function:function(x-1,function)*x if x>0 else 1)

参数:

(x-1,lambda x,function:function(x-1,function)*x if x>0 else 1)

*x if x>0 else 1

错误分析

function(未给出定义)

 1.error:

(lambda x,function:function(x-1,function)*x if x>0 else 1)

(x-1,function)*x if x>0 else 1

2.error:

(lambda x,function:function(x-1,function)*x if x>0 else 1)

(x,function)

pass情况:

PS D:\pycharm\python document\CS61A class homework\hw03> python3 ok -q make_anonymous_factorial
=====================================================================
Assignment: Homework 3
OK, version v1.18.1
=====================================================================

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests

---------------------------------------------------------------------
Test summary
    1 test cases passed! No cases failed.

Backup... 100% complete
Backup past deadline by 1245 days, 3 hours, 43 minutes, and 25 seconds


OK is up to date

 完整答案:

HW_SOURCE_FILE=__file__


def composer(func=lambda x: x):
    """
    Returns two functions -
    one holding the composed function so far, and another
    that can create further composed problems.
    >>> add_one = lambda x: x + 1
    >>> mul_two = lambda x: x * 2
    >>> f, func_adder = composer()
    >>> f1, func_adder = func_adder(add_one)
    >>> f1(3)
    4
    >>> f2, func_adder = func_adder(mul_two)
    >>> f2(3) # should be 1 + (2*3) = 7
    7
    >>> f3, func_adder = func_adder(add_one)
    >>> f3(3) # should be 1 + (2 * (3 + 1)) = 9
    9
    """
    def func_adder(g):
        "*** YOUR CODE HERE ***"
        return  composer(lambda x:func(g(x)))

    return func, func_adder


def g(n):
    """Return the value of G(n), computed recursively.

    >>> g(1)
    1
    >>> g(2)
    2
    >>> g(3)
    3
    >>> g(4)
    10
    >>> g(5)
    22
    >>> from construct_check import check
    >>> # ban iteration
    >>> check(HW_SOURCE_FILE, 'g', ['While', 'For'])
    True
    """
    "*** YOUR CODE HERE ***"
    if n<=3:
        return n
    else:
        return g(n-1)+2*g(n-2)+3*g(n-3)


def g_iter(n):
    """Return the value of G(n), computed iteratively.

    >>> g_iter(1)
    1
    >>> g_iter(2)
    2
    >>> g_iter(3)
    3
    >>> g_iter(4)
    10
    >>> g_iter(5)
    22
    >>> from construct_check import check
    >>> # ban recursion
    >>> check(HW_SOURCE_FILE, 'g_iter', ['Recursion'])
    True
    """
    "*** YOUR CODE HERE ***"
    if n<=3:
        return n
    else:
        f1=1
        f2=2
        f3=3
        f4=3*f1+2*f2+f3
        while n>4:
            f1=f2
            f2=f3
            f3=f4
            f4=3*f1+2*f2+f3
            n-=1
        return f4




def missing_digits(n):
    """Given a number a that is in sorted, increasing order,
    return the number of missing digits in n. A missing digit is
    a number between the first and last digit of a that is not in n.
    >>> missing_digits(1248) # 3, 5, 6, 7
    4
    >>> missing_digits(1122) # No missing numbers
    0
    >>> missing_digits(123456) # No missing numbers
    0
    >>> missing_digits(3558) # 4, 6, 7
    3
    >>> missing_digits(35578) # 4, 6
    2
    >>> missing_digits(12456) # 3
    1
    >>> missing_digits(16789) # 2, 3, 4, 5
    4
    >>> missing_digits(19) # 2, 3, 4, 5, 6, 7, 8
    7
    >>> missing_digits(4) # No missing numbers between 4 and 4
    0
    >>> from construct_check import check
    >>> # ban while or for loops
    >>> check(HW_SOURCE_FILE, 'missing_digits', ['While', 'For'])
    True
    """
    "*** YOUR CODE HERE ***"
    if n//10==0:
        return 0
    last=n%10
    n=n//10
    if n%10<last:
        dec=last-1-n%10
    else:
        dec=0
    return missing_digits(n)+dec


def divide(total,num):
    if num==1:
        return 1
    if total<num:
        return divide(total,num/2)
    return divide(total-num,num)+divide(total,num/2)

def max1(total):
    if total<=1:
        return 1
    if total>0:
        return max1(total//2)*2
def count_change(total):
    """Return the number of ways to make change for total.

    >>> count_change(7)
    6
    >>> count_change(10)
    14
    >>> count_change(20)
    60
    >>> count_change(100)
    9828
    >>> from construct_check import check
    >>> # ban iteration
    >>> check(HW_SOURCE_FILE, 'count_change', ['While', 'For'])
    True
    """
    "*** YOUR CODE HERE ***"
    if total==1:
        return 1
    return divide(total,max1(total))


def print_move(origin, destination):
    """Print instructions to move a disk."""
    print("Move the top disk from rod", origin, "to rod", destination)


def move_stack(n, start, end):
    """Print the moves required to move n disks on the start pole to the end
    pole without violating the rules of Towers of Hanoi.

    n -- number of disks
    start -- a pole position, either 1, 2, or 3
    end -- a pole position, either 1, 2, or 3

    There are exactly three poles, and start and end must be different. Assume
    that the start pole has at least n disks of increasing size, and the end
    pole is either empty or has a top disk larger than the top n start disks.

    >>> move_stack(1, 1, 3)
    Move the top disk from rod 1 to rod 3
    >>> move_stack(2, 1, 3)
    Move the top disk from rod 1 to rod 2
    Move the top disk from rod 1 to rod 3
    Move the top disk from rod 2 to rod 3
    >>> move_stack(3, 1, 3)
    Move the top disk from rod 1 to rod 3
    Move the top disk from rod 1 to rod 2
    Move the top disk from rod 3 to rod 2
    Move the top disk from rod 1 to rod 3
    Move the top disk from rod 2 to rod 1
    Move the top disk from rod 2 to rod 3
    Move the top disk from rod 1 to rod 3
    """
    assert 1 <= start <= 3 and 1 <= end <= 3 and start != end, "Bad start/end"
    "*** YOUR CODE HERE ***"
    n_s=0
    if 1!=start and 1!=end:
        n_s=1
    if 2!=start and 2!=end:
        n_s=2
    if 3!=start and 3!=end:
        n_s=3
    if n==1:
        print_move(start,end)
        return
    if n==2:
        print_move(start,n_s)
        print_move(start,end)
        print_move(n_s,end)
        return
    move_stack(n-1,start,n_s)
    print_move(start,end)
    move_stack(n-1,n_s,end)


from operator import sub, mul

def make_anonymous_factorial():
    """Return the value of an expression that computes factorial.

    >>> make_anonymous_factorial()(5)
    120
    >>> from construct_check import check
    >>> # ban any assignments or recursion
    >>> check(HW_SOURCE_FILE, 'make_anonymous_factorial', ['Assign', 'AugAssign', 'FunctionDef', 'Recursion'])
    True
    """
    return lambda x:(lambda x,function:function(x-1,function)*x if x>0 else 1)(x-1,lambda x,function:function(x-1,function)*x if x>0 else 1)*x if x>0 else 1

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/221446.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

ESP32-Web-Server编程-在网页中插入图片

ESP32-Web-Server编程-在网页中插入图片 概述 图胜与言&#xff0c;在网页端显示含义清晰的图片&#xff0c;可以使得内容更容易理解。 需求及功能解析 本节演示在 ESP32 Web 服务器上插入若干图片。在插入图片时还可以对图片设置一个超链接&#xff0c;用户点击该图片时&a…

统计项目代码行数轻松搞定:使用 Node.js 脚本自动统计代码量

说在前面 在软件开发领域&#xff0c;了解项目的代码规模和复杂度对于项目管理、团队协作以及技术评估都至关重要。通过统计项目代码行数&#xff0c;我们能够更好地把握项目的整体情况&#xff0c;包括但不限于代码量的大小、不同类型文件的分布情况以及项目的结构和复杂度。这…

数据结构之选择排序

目录 直接选择排序 选择排序的时间复杂度 堆排序 向上调整算法 向下调整算法 向上调整算法建立堆 向下调整算法建立堆 堆排序整体代码 堆排序的时间复杂度 直接选择排序 在之前讲插入排序时&#xff0c;我们讲了这样的一个应用场景&#xff0c;我们在斗地主摸牌时&…

CoreDNS实战(十一)-分流与重定向

本文主要介绍了目前CoreDNS服务在外部域名递归结果过程中出现的一些问题以及使用dnsredir插件进行分流和alternate插件进行重试优化的操作。 1 自建DNS服务现状 一般来说&#xff0c;无论是bind9、coredns、dnsmasq、pdns哪类dns服务器&#xff0c;我们自建的监听在UDP53端口…

【已解决】页内切换<router-view>使得url变化导致菜单高亮消失

在写项目时&#xff0c;我们常会用到侧边菜单栏&#xff0c;而具体页面中经常使用<router-view>切换子组件。 但是按照我们平时的写法&#xff0c;切换子组件后会导致url改变&#xff0c;从而使得菜单高亮消失&#xff0c;这是非常影响用户体验的。 所以&#xff0c;我…

圈子社交系统:打破时间与空间的限制。APP小程序H5三端源码交付,支持二开!

在现代社会&#xff0c;社交已成为人们生活中不可或缺的一部分。然而&#xff0c;传统的社交方式往往受制于时间和空间的限制&#xff0c;使得人们难以充分发挥社交的潜力。为了解决这一问题&#xff0c;圈子社交系统应运而生。 圈子社交系统通过技术手段打破时间与空间的限制&…

想考研到电子类,未来从事芯片设计,目前该怎么准备?

最近看不少天坑学子想考研微电子专业&#xff0c;但却不知道该怎么准备&#xff1f;接下来就带大家一起来具体了解一下~ 首先是目标院校的选择&#xff1f; 目前所设的微电子专业学校里&#xff0c;比较厉害的有北京大学、清华大学、中国科学院大学、复旦大学、上海交通大学、…

探索人工智能领域——每日20个名词详解【day9】

目录 前言 正文 总结 &#x1f308;嗨&#xff01;我是Filotimo__&#x1f308;。很高兴与大家相识&#xff0c;希望我的博客能对你有所帮助。 &#x1f4a1;本文由Filotimo__✍️原创&#xff0c;首发于CSDN&#x1f4da;。 &#x1f4e3;如需转载&#xff0c;请事先与我联系以…

flex 布局防止元素被挤换行

刚开始是这样的代码&#xff1a; <div class"flex"><span>选择模型&#xff1a;</span><n-select :options"state.chatModelOptions" /> </div>选择模型换行了…不行&#xff0c;这个效果不行&#xff0c;修改后&#xff1…

基于STM32驱动的压力传感器实时监测系统

本文介绍了如何使用STM32驱动压力传感器进行实时监测。首先&#xff0c;我们会介绍压力传感器的工作原理和常见类型。然后&#xff0c;我们将介绍如何选择合适的STM32单片机和压力传感器组合。接下来&#xff0c;我们会详细讲解如何使用STM32驱动压力传感器进行数据采集和实时监…

647. Palindromic Substrings 516. Longest Palindromic Subsequence

647. Palindromic Substrings Given a string s, return the number of palindromic substrings 回文子串 in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string. nomal: …

玄子Share-CSS3 弹性布局知识手册

玄子Share-CSS3 弹性布局知识手册 Flexbox Layout&#xff08;弹性盒布局&#xff09;是一种在 CSS 中用于设计复杂布局结构的模型。它提供了更加高效、简便的方式来对容器内的子元素进行排列、对齐和分布 主轴和交叉轴 使用弹性布局&#xff0c;最重要的一个概念就是主轴与…

服务器数据恢复—重装系统导致XFS文件系统分区丢失的数据恢复案例

服务器数据恢复环境&#xff1a; 服务器使用磁盘柜RAID卡搭建了一组riad5磁盘阵列。服务器上层分配了一个LUN&#xff0c;划分了两个分区&#xff1a;sdc1分区和sdc2分区。通过LVM扩容的方式&#xff0c;将sdc1分区加入到了root_lv中&#xff1b;sdc2分区格式化为XFS文件系统。…

iptables的源地址、目标地址转换

目录 一、实验准备 二、配置web服务器 三、配置web防火墙网卡 四、配置客户机网卡 五、测试 1、开启防火墙功能&#xff0c;设置源地址转换&#xff0c;通过改变我客户机的地址身份为web服务器同网段来实现访问 2、通过改变目标地址&#xff08;客户机&#xff09;的地址…

力扣973. 最接近原点的 K 个点(java 排序法,大顶堆法)

Problem: 973. 最接近原点的 K 个点 文章目录 题目描述思路解题方法复杂度Code 题目描述 给定一个数组 points &#xff0c;其中 points[i] [xi, yi] 表示 X-Y 平面上的一个点&#xff0c;并且是一个整数 k &#xff0c;返回离原点 (0,0) 最近的 k 个点。 这里&#xff0c;平面…

gitLab创建新项目

1.进入git2.选择创建项目3.勾选生成readme.md文件4.邀请成员

如何借助Instagram群发工具更为精准、高效的市场拓展

在当今全球化的商业舞台上&#xff0c;Instagram作为一种强大的社交媒体平台&#xff0c;已成为跨海商家推广产品和服务的理想选择。为了更有效地利用这一平台&#xff0c;跨海商家纷纷借助Instagram群发工具&#xff0c;通过智能化的推广方式&#xff0c;实现了更为精准、高效…

17、迭代器模式(Iterator Pattern)

迭代器模式提供了顺序访问集合对象中的各种元素&#xff0c;而不暴露该对象内部结构的方法。如Java中遍历HashMap。 迭代器模式将遍历集合中所有元素的操作封装成迭代器类&#xff0c;其目的是在不暴露集合对象内部结构的情况下&#xff0c;对外提供统一访问集合的内部数据的方…

D6208单片双向马达驱动电路国产芯片,工作电源电压范围宽(4.5V~15.0V),内设保护二极管采用SOP8封装

D6208 是一块单片双向马达驱动电路&#xff0c;它使用TTL电平的逻辑信号就能控制卡式录音机和其它电子设备中的双向马达。该电路由一个逻辑部分和一个功率输出部分组成。逻辑部分控制马达正、反转向及制动&#xff0c;功率输出部分根据逻辑控制能提供100mA&#xff08;典型值&a…

nodejs微信小程序+python+PHP在线购票系统的设计与实现-计算机毕业设计推荐

目 录 摘 要 I ABSTRACT II 目 录 II 第1章 绪论 1 1.1背景及意义 1 1.2 国内外研究概况 1 1.3 研究的内容 1 第2章 相关技术 3 2.1 nodejs简介 4 2.2 express框架介绍 6 2.4 MySQL数据库 4 第3章 系统分析 5 3.1 需求分析 5 3.2 系统可行性分析 5 3.2.1技术可行性&#xff1a;…