<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href='http://feed.feedsky.com/styles/temp01.xsl' type='text/xsl' ?><!--这是一个由Feedsy提供技术支持的Feed，为了提高读者阅读的体验，以及满足用户美化自己Feed的需要，我们设计了多种精美的Feed模板，提供给大家选择，所有最终呈现出来的样式，皆由用户自愿选择使用，未经许可，任何团体和个人，请不要擅自修改样式或者盗用，这是对于用户选择权的尊重。--><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://www.feedsky.com/namespace/feed" xmlns:live="http://schemas.microsoft.com/live/spaces/2006/rss/" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dcterms="http://purl.org/dc/terms/" version="2.0"><channel><atom:link href="http://feed.feedsky.com/knightsgang" type="application/rss+xml" rel="self"></atom:link><fs:self_link href="http://feed.feedsky.com/knightsgang" type="application/rss+xml"></fs:self_link><lastBuildDate>Tue, 16 Mar 2010 15:33:43 GMT</lastBuildDate><title>长驱直入骑士帮</title><description>长驱直入骑士帮</description><link>http://knightsgang.spaces.live.com/</link><live:type>main</live:type><live:typelabel>Main</live:typelabel><live:identity><live:id>6140167007899810239</live:id><live:alias>knightsgang</live:alias></live:identity><cf:listinfo><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss/" element="typelabel" label="Type"></cf:group><cf:sort element="pubDate" label="Date" data-type="date" default="true"></cf:sort><cf:sort element="title" label="Title" data-type="string"></cf:sort></cf:listinfo><language>en-us</language><pubDate>Fri, 30 Jan 2009 07:58:05 GMT</pubDate><image><title>长驱直入骑士帮</title><url>http://byfiles.storage.msn.com/y1mfq5bRurh49tkAwccSSc4TrER7mOn_DO_ydW5WO8Li-C7C1FuRrK45YfX12WbuzLVqi18nMvhjl3ObyuW2Ml34g</url><link>http://knightsgang.spaces.live.com/</link></image><item><title>目录与文件属性:编写ls 习题</title><link>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!166.entry</link><slash:comments>0</slash:comments><live:type>blogentry</live:type><live:typelabel>Blog Entry</live:typelabel><wfw:commentRss>http://cid-5536415c9770f9bf.users.api.live.net:80/Users(6140167007899810239)/Blogs('5536415C9770F9BF!119')/Entries('5536415C9770F9BF!166')/Comments?$format=application%2frss%2bxml</wfw:commentRss><dcterms:modified>2010-03-16T15:33:43.3600000Z</dcterms:modified><description>&lt;p&gt;3.3 &lt;u&gt;每个用户都有用户名,每个用户名都有对应的用户ID,是否可能两个不同的用户名对应一个相同的ID?是否允许同一个用户拥有两个不同的 ID?如果有root权限,可以试一试,创建两个用户,改成同一个ID,但有不同的用户名和密码,这两个用户是否可以修改对方的文件?who输出什么?ls -l输出什么?命令id输出什么?相互发送Email呢?从中能够看出些什么?多个用户使用同一个ID还有什么其它用途?&lt;/u&gt;&lt;/p&gt; &lt;p&gt;      a.两个不同的用户名可以对应一个相同的ID. &lt;br /&gt;添加名为beta的用户到系统中，并更改密码&lt;/p&gt; &lt;div&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;useradd beta&lt;br /&gt;passwd beta&lt;/pre&gt;查看alpha,beta的id信息&lt;/div&gt;
&lt;div&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;id alpha&lt;br /&gt;id beta&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;通过修改/etc/passwd文件改变beta的uid&lt;/div&gt;
&lt;div&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;vi /etc/passwd&lt;/pre&gt;改变test文件的用户和组属性&lt;/div&gt;
&lt;div&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;chown beta&amp;#58;beta test&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;以下是一系列测试&lt;/div&gt;
&lt;div&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;ls -l test&lt;br /&gt;$ ls -l test&lt;br /&gt;-rw-r--r-- 1 alpha beta 28 2010-02-19 18&amp;#58;23 test&lt;br /&gt;$ id alpha&lt;br /&gt;uid=1000(alpha) gid=1000(alpha) 组=1000(alpha),4(adm),20(dialout),24(cdrom),46(plugdev),106(lpadmin),121(admin),122(sambashare),125(uml-net)&lt;br /&gt;$ id beta&lt;br /&gt;uid=1000(alpha) gid=1000(alpha) 组=1000(alpha)&lt;br /&gt;$ ./who2&lt;br /&gt;beta     tty2     Feb 19 18&amp;#58;21&lt;br /&gt;alpha    tty7     Feb 19 18&amp;#58;27&lt;br /&gt;alpha    pts/0    Feb 19 18&amp;#58;47&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;b.同一个用户不能拥有两个ID.即使在/etc/passswd中添加另一个ID,系统也只使用第一条记录.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;c.不同用户名对应一个相同的UID,相互发送Email&amp;#58; &lt;br /&gt;如果内部程序以用户名为依据,alpha与beta各自接收自己的邮件 &lt;br /&gt;如果以 UID为依据,alpha与beta会同时接收对方的邮件 &lt;br /&gt;从中可以看到程序设计方面可以依据于用户名或UID,两种方式有各自的优点.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;p&gt;&lt;u&gt;3.4 与普通的文件一样,目录也有特殊属性位,其中包含set-user-ID和set-group-ID位,使set-user-ID有效对目录有什么影响,如果有,那么是什么?为什么?如果没有影响,那么你能想象出这些位有什么作用吗?&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;a.set- user-ID对目录没有影响. &lt;br /&gt;b.set-group-ID对目录有影响.&lt;/p&gt;
&lt;p&gt;例如&amp;#58; &lt;br /&gt;root用户&amp;#58; &lt;br /&gt;mkdir /test &lt;br /&gt;chmod 777 /test &lt;br /&gt;test用户&amp;#58; &lt;br /&gt;touch /test/test1 &lt;br /&gt;ls -l /test/test1 &lt;br /&gt;-rw-r--r-- 1 test1 test2 0 2009-01-17 23&amp;#58;31 /test/test1 &lt;br /&gt;设置set-group-ID位&amp;#58; &lt;br /&gt;chmod 2777 /test &lt;br /&gt;test 用户&amp;#58; &lt;br /&gt;touch /test/test2 &lt;br /&gt;ls -l /test/* &lt;br /&gt;-rw-r--r-- 1 test1 test2 0 2009-01-17 23&amp;#58;31 /test/test1 &lt;br /&gt;-rw-r--r-- 1 test1 root  0 2009-01-17 23&amp;#58;33 /test/test2 &lt;br /&gt;测试结果说明,用目录设置了set-group-ID位,在该目录下新建文件的组同父目录的组一致. &lt;/p&gt;
&lt;p&gt;3.5 &lt;u&gt;每个文件的执行权限都可以被打开或关闭,假设一个纯文本文件具有执行权限,它是否可以被执行,如果一个包含可执行代码的文件,如对 C语言编译后的可执行文件a.out,没有执行权限的话,它是否可以被执行?讨论执行权限和可执行代码之间的区别.它们之间的关系吗?参见命令file的联机帮助 &lt;br /&gt;&lt;/u&gt;解答&amp;#58; &lt;br /&gt;1)它可以执行,它是以Shell script的方式执行. &lt;br /&gt;2)对C语言编译的可执行文件a.out,没有执行权限是不可以被执行的. &lt;br /&gt;3)执行权限本身是一种存储在inode中的数据结构.可执行代码仅是物理文件内部的一种组织结构. &lt;br /&gt;例如用file查看文件类型&amp;#58; &lt;br /&gt;file /etc/passwd /bin/ls &lt;br /&gt;/bin/ls&amp;#58;    ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), stripped &lt;br /&gt;/etc/passwd&amp;#58; ASCII text &lt;br /&gt;用objdump名字查看可执行文件的头信息 &amp;#58; &lt;br /&gt;objdump -xd /bin/ls|more &lt;br /&gt;/bin/ls&amp;#58;     file format elf32-i386 &lt;br /&gt;/bin/ls &lt;br /&gt;architecture&amp;#58; i386, flags 0x00000112&amp;#58; &lt;br /&gt;EXEC_P, HAS_SYMS, D_PAGED &lt;br /&gt;start address 0x08049a80&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;3.6 &lt;u&gt;每个用户都有用户名和用户ID,这可以被认为是两种标识系统,为什么要这样?能不能直接用户名来表示文件所有者?为什么?能不能只用其中一种标识系统?两套表示系统有什么优缺点?如果由你来设计系统,你会如何设计? &lt;br /&gt;&lt;/u&gt;解答&amp;#58; &lt;br /&gt;1)两种标识系统分别针对于用户管理与系统管理. &lt;br /&gt;2)不能用用户名来表示文件所有者,因为文件的所有者与所属组存储于inode节点中. &lt;br /&gt;使用用户名管理系统只是方便于用户层面的应用管理.而内核用inode节点中的uid和gid管理文件和识别文件所有者 &lt;br /&gt;3)Unix/Linux一直沿用这两套管理方式来管理文件所有者.而Windows系统则沿用用户名的管理方式. &lt;br /&gt;UNIX的管理方式,主要优点是授权与管理更集中于用户及UID上.比如uid为0代表 Root用户权限.而另外一个用户如果UID为0,即 &lt;br /&gt;同样拥有Root权限,这一切不依赖于用户名. &lt;br /&gt;而WINDOWS管理方式如果要达到以上的效果,只能用组的方式来管理,即将要授权的用户归属于administrators组. &lt;br /&gt;4)系统的设计是一个全方面的设计过程,依据于对文件,对inode,对用户的管理等等. &lt;br /&gt;而一部系统应该包括有用户名和用户名对应的ID,而对应用层面有效的管理应该用用户名,而系统内部的运行和执行流程的控制 &lt;br /&gt;应该用ID.&lt;/p&gt;
&lt;p&gt;3.7&lt;u&gt; 命令dirent的联机帮助中提到了系统调用getdents(2),它的功能是什么?与readdir有什么关系? &lt;br /&gt;&lt;/u&gt;解答&amp;#58; &lt;br /&gt;man getdents &lt;br /&gt;This is not the function you are interested in.  Look at readdir(3) for &lt;br /&gt;       the POSIX conforming C library interface.  This page documents the bare &lt;br /&gt;       kernel system call interface. &lt;br /&gt;       The  system  call  getdents()  reads several dirent structures from the &lt;br /&gt;       directory pointed at by fd into the memory area  pointed  to  by  dirp. &lt;br /&gt;       The parameter count is the size of the memory area. &lt;br /&gt;int getdents(unsigned int fd, struct dirent *dirp, unsigned int count); &lt;br /&gt;其中fd为指向目录文件的文件描述符，该函数根据fd所指向的目录文件读取相应dirent结构，并放入dirp中，其中count为dirp中返回的数据量，正确时该函数返回值为填充到dirp的字节数当查询文件或者目录的相关信息时，Linux系统用sys_getedents 来执行相应的查询操作，并把得到的信息传递给用户空间运行的程序该调用返回的项的格式和struct dirent 不同，因此用户应该尽量使用可移植的POSIX 函数 readdir &lt;br /&gt;struct dirent *readdir(DIR *dir)读取目录,返回一个指向目录的当前记录的指针.&lt;/p&gt;
&lt;p&gt;3.8 &lt;u&gt;命令ls -l的输出中有这样的一项drwxr-xr-x,表示这是一个目录,它的文件甩有者有全部权限,组用户和其它用户只有读和执行的权限,对于文件而言,执行权限意味着计算机可以执行其中包含的机器代码或脚本语句,对于目录而言,执行权限有什么意思?可以用chmod来关掉这个目录的执行权限.看看会发生什么? &lt;br /&gt;&lt;/u&gt;解答&amp;#58; &lt;br /&gt;目录有读权限可以列出目录的文件,即有读权限可以读取directory数据结构中的内容,反之则不能 &lt;br /&gt;读取目录信息,比如&amp;#58;ls -l /test/ &lt;br /&gt;ls&amp;#58; cannot open directory /test/&amp;#58; Permission denied &lt;br /&gt;目录有写权限,即有写权限写入到directory数据结构中.反之则不能写入到目录中.比如&amp;#58; &lt;br /&gt;touch test &lt;br /&gt;touch&amp;#58; cannot touch `test'&amp;#58; Permission denied &lt;br /&gt;目录有执行权限,即有进入到目录的权限.反之则不能进入目录.比如&amp;#58; &lt;br /&gt;cd /test/ &lt;br /&gt;-su&amp;#58; cd&amp;#58; /test/&amp;#58; Permission denied&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/414071395/knightsgang/feedsky/s.gif?r=http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!166.entry&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/knightsgang/414071395/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/knightsgang/414071395/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><pubDate>Tue, 16 Mar 2010 23:33:43 +0800</pubDate><comments>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!166.entry#comment</comments><guid isPermaLink="false">5536415C9770F9BF!166</guid><fs:srclink>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!166.entry</fs:srclink><fs:srcfeed>http://cid-5536415c9770f9bf.users.api.live.net/Users(6140167007899810239)/Main?$format=rss20</fs:srcfeed><fs:itemid>feedsky/knightsgang/~7720050/414071395/5829218</fs:itemid></item><item><title>用户、文件操作与联机帮助---习题解答</title><link>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!165.entry</link><slash:comments>0</slash:comments><live:type>blogentry</live:type><live:typelabel>Blog Entry</live:typelabel><wfw:commentRss>http://cid-5536415c9770f9bf.users.api.live.net:80/Users(6140167007899810239)/Blogs('5536415C9770F9BF!119')/Entries('5536415C9770F9BF!165')/Comments?$format=application%2frss%2bxml</wfw:commentRss><dcterms:modified>2010-02-08T12:30:59.7600000Z</dcterms:modified><description>&lt;p&gt;&lt;font face=&quot;宋体&quot;&gt;感谢&lt;/font&gt;&lt;a href=&quot;http&amp;#58;//www.lupaworld.com/56821/viewspace-117447.html&quot; target=&quot;_blank&quot;&gt;&lt;font face=&quot;宋体&quot;&gt;超级玛丽&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;宋体&quot;&gt;博客的帮助。 &lt;br /&gt;&lt;/font&gt;&lt;font face=&quot;宋体&quot;&gt;2.1 &lt;/font&gt;&lt;u&gt;&lt;font face=&quot;宋体&quot;&gt;在UNIX中有一个w命令,这个命令与who有关,运行这个命令,并阅读它的联想帮助,找出它提供了哪些who没有提供的信息? &lt;br /&gt;其中有哪些信息来自utmp这个文件,这些信息各是什么含义?其他信息来自哪里?&lt;/font&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;  w - Show who is logged on and what they are doing.&lt;br /&gt;    例如，按下w后的输出为：&lt;br /&gt;15&amp;#58;04&amp;#58;04 up 2 min,  2 users,  load average&amp;#58; 1.02, 0.63, 0.24&lt;br /&gt;USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT&lt;br /&gt;alpha    tty7     &amp;#58;0               15&amp;#58;02    2&amp;#58;17  11.06s  0.13s gnome-session&lt;br /&gt;alpha    pts/0    &amp;#58;0.0             15&amp;#58;04    0.00s  0.35s  0.01s w&lt;br /&gt;    而按下who后的输出为：&lt;br /&gt;alpha    tty7         2010-02-04 15&amp;#58;02 (&amp;#58;0)&lt;br /&gt;alpha    pts/0        2010-02-04 15&amp;#58;04 (&amp;#58;0.0)&lt;br /&gt;    手册中提示到&amp;#58;&lt;br /&gt;    The header shows, in this order,  the  current  time,&lt;br /&gt;how  long  the  system  has  been running, how many users are currently&lt;br /&gt;logged on, and the system load averages for the past 1, 5, and 15  minutes.&lt;br /&gt;    信息来自/var/run/utmp和/proc两个文件。&lt;/p&gt;&lt;font face=&quot;宋体&quot;&gt; &lt;p&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/p&gt;&lt;/font&gt;&lt;font face=&quot;宋体&quot;&gt;&lt;u&gt;2.2 用户登录的时候,登录信息会被记录在utmp文件中,在注销的时候，文件中相应的记录会被删除.如果用户正在使用系统的时候，系统突然崩溃，很明显，这时候utmp文件的内容会有问题，在系统重新启动的时候，会对utmp做文件处器呢？系统会不会重新为每一条可用终端建立记录？查阅相关的联机帮助和头文件，以及启动脚本，来找出上述问题的答案，可以在自己的机器上做实验来验证自己的想法. &lt;br /&gt;&lt;/u&gt;&lt;/font&gt;&lt;font face=&quot;宋体&quot; size=&quot;2&quot;&gt;&lt;br /&gt;囿于目前所知，在ＵＢＵＮＴＵ系统下面找不到有帮助的信息，貌似ＵＢＵＮＴＵ的启动同其他Ｌｉｎｕｘ发行版本有很大不同。 &lt;br /&gt;&lt;/font&gt;&lt;font face=&quot;宋体&quot; size=&quot;2&quot;&gt;以下是来自超级玛丽博客的解答： &lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face=&quot;宋体&quot; size=&quot;2&quot;&gt;系统引导的时候，会执行/etc/rc.sysinit脚本文件. &lt;br /&gt;在/etc/rc.sysinit脚本文件中找到以下行. &lt;br /&gt;# Clean up utmp/wtmp &lt;br /&gt;&amp;gt; /var/run/utmp &lt;br /&gt;touch /var/log/wtmp &lt;br /&gt;chgrp utmp /var/run/utmp /var/log/wtmp &lt;br /&gt;chmod 0664 /var/run/utmp /var/log/wtmp &lt;br /&gt;说明在重新启动的时候，系统会清空/var/run/utmp文件，系统不会重新为每一条可用终端建立记录. 对wtmp文件，如果有wtmp文件，同步时间戳，没有wtmp文件，则新建空的wtmp文件. &lt;br /&gt;utmp文件是当前系统中，用户连线的记录，用户LOGIN则插入记录到utmp文件，LOGOUT则删除记录.用w/who命令可查看. wtmp文件是系统记录用户登入/登出历史.用 last命令可查看.&lt;/font&gt;  &lt;p&gt;&lt;font face=&quot;宋体&quot; size=&quot;2&quot;&gt;2.3 &lt;u&gt;做个实验，把一个文件复制到/dev/tty&amp;#58;cp1 cp1.c /dev/tty .这时复制的目标文件是一个终端。对终端的读写操作与一个普通文件进行读写是一样的.接下来做实验，从终端读，这时会从键盘读写字符。然后写入到文件中，输入是以回车符+[CTRL-D] 作为结束标志的. &lt;br /&gt;&lt;/u&gt;&lt;/font&gt;&lt;font face=&quot;宋体&quot; size=&quot;2&quot;&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/font&gt;&lt;font face=&quot;宋体&quot; size=&quot;2&quot;&gt;    /dev/tty 是当前的终端. &lt;br /&gt;    ./cp1 cp1.c /dev/tty 将cp1.c文件中的内中输出到当前终端上. &lt;br /&gt;    同样的，./cp1  /dev/tty test 将当前终端上的内容输出到test文件中.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;宋体&quot; size=&quot;2&quot;&gt;2.4 &lt;u&gt;标准C函数如fopen,getc,fclose,fgets的实现都包含内核级的缓冲,它们用到了一个结构FILE，并以此为基础构造了类似 utmplib的中间层,在头文件中找到结构FILE的成员描述。将其与utmplib.c中的变量做比较.&lt;/u&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;宋体&quot; size=&quot;2&quot;&gt;    stdio.h中显示&amp;#58;&lt;/font&gt;&lt;span style=&quot;display&amp;#58;none&quot;&gt;&lt;/span&gt; &lt;/p&gt; &lt;div&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;typedef&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;struct&lt;/span&gt; _IO_FILE FILE&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;display&amp;#58;none&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;display&amp;#58;none&quot;&gt;    这意味着FILE 是_IO_FILE的别名，最终在libio.h中找到了_IO_FILE的定义：&lt;/span&gt;&lt;span style=&quot;display&amp;#58;none&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;struct&lt;/span&gt; _IO_FILE &amp;#123;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; _flags;        &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* High-order word is _IO_MAGIC; rest is flags. */&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#define&lt;/span&gt; _IO_file_flags _flags&lt;br /&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* The following pointers correspond to the C++ streambuf protocol. */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* Note&amp;#58;  Tk uses the _IO_read_ptr and _IO_read_end fields directly. */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt;* _IO_read_ptr;    &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* Current read pointer */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt;* _IO_read_end;    &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* End of get area. */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt;* _IO_read_base;    &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* Start of putback+get area. */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt;* _IO_write_base;    &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* Start of put area. */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt;* _IO_write_ptr;    &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* Current put pointer. */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt;* _IO_write_end;    &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* End of put area. */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt;* _IO_buf_base;    &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* Start of reserve area. */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt;* _IO_buf_end;    &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* End of reserve area. */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* The following fields are used to support backing up and undo. */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt; *_IO_save_base; &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* Pointer to start of non-current get area. */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt; *_IO_backup_base;  &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* Pointer to first valid character of backup area */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt; *_IO_save_end; &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* Pointer to end of non-current get area. */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;struct&lt;/span&gt; _IO_marker *_markers;&lt;br /&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;struct&lt;/span&gt; _IO_FILE *_chain;&lt;br /&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; _fileno;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#if&lt;/span&gt; 0&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; _blksize;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#else&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; _flags2;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#endif&lt;/span&gt;&lt;br /&gt;  _IO_off_t _old_offset; &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* This used to be _offset but it's too small.  */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#define&lt;/span&gt; __HAVE_COLUMN &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* temporary */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/* 1+column number of pbase(); 0 is unknown. */&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;unsigned&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;short&lt;/span&gt; _cur_column;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;signed&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt; _vtable_offset;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt; _shortbuf[1];&lt;br /&gt;&lt;br /&gt;  &lt;span style=&quot;color&amp;#58;#008000&quot;&gt;/*  char* _save_gptr;  char* _save_egptr; */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  _IO_lock_t *_lock;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#ifdef&lt;/span&gt; _IO_USE_OLD_IO_FILE&lt;br /&gt;&amp;#125;;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;     我们在utmplib.h有起到类似作用的变量：&lt;/div&gt;
&lt;div&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#define&lt;/span&gt; NRECS 16&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#define&lt;/span&gt; UTSIZE (&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;sizeof&lt;/span&gt; utmp)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt; utmpbuf[NRCES*UTSIZE];&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt;  fd_utmp;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; cur_rec;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; num_recs;&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;注意到，带有buf字眼的&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt;* _IO_buf_base，&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt;* _IO_buf_end用来描述缓冲取区的，这与utmplib.h中的utmpbuf的作用类似。 &lt;br /&gt;      &lt;br /&gt;&lt;font size=&quot;4&quot;&gt;p.s&amp;#58;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size=&quot;1&quot;&gt;&lt;font face=&quot;宋体&quot;&gt;     &lt;font size=&quot;2&quot;&gt;open()和&lt;font size=&quot;2&quot;&gt;fopen()&lt;/font&gt;的区别：&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;p&gt;前者属于低级IO，后者是高级IO。 &lt;br /&gt;前者返回一个文件描述符(用户程序区的)，后者返回一个文件指针。 &lt;br /&gt;前者无缓冲，后者有缓冲。 &lt;br /&gt;前者与 read, write 等配合使用， 后者与 fread, fwrite等配合使用。 &lt;br /&gt;后者是在前者的基础上扩充而来的，在大多数情况下，用后者。 &lt;br /&gt;open 是系统调用 fopen是C的库函数。&lt;/p&gt;
&lt;p&gt;2.5 &lt;u&gt;怎么来确定数据已经被写到磁盘上(不是被缓冲)?采用缓冲技术时，内核会把要写入磁盘的数据放在缓冲区，然后在它认为合适的时候定候写入磁盘。阅读相应的联机帮助，找到能够确定地把数据写入磁盘的方法.&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;A successful return from write() does not make any guarantee that data has been committed to  disk. In fact,  on  some  buggy  implementations,  it  does  not  even guarantee that space has successfully been reserved for the data. The only way to be sure is to call &lt;strong&gt;&lt;em&gt;fsync(2)&lt;/em&gt;&lt;/strong&gt; after you are done writing all  your  data.&lt;/p&gt;
&lt;p&gt;2.6&lt;u&gt; UNIX允许一个文件同时被多个进程打开，也允许一个进程同时打开好几个文件，做多次打开文件的实验&amp;#58; &lt;br /&gt;(1)以读的方式打开文件 &lt;br /&gt;(2)以写的方式打开文件 &lt;br /&gt;(3)再次以读的方式打开文件 &lt;br /&gt;这时有3个文件描述符，接下来&amp;#58; &lt;br /&gt;(4)从第一个文件描述符(以下简称fd)中读 20字符，显示读到的内容. &lt;br /&gt;(5)从第二个fd写入&amp;quot;testing 123...&amp;quot;. &lt;br /&gt;(6)从第三个fd读出20字符，显示读到的内容.&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;   源程序如下：&lt;/p&gt;
&lt;div&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#include&lt;/span&gt; &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#include&lt;/span&gt; &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#include&lt;/span&gt; &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#define&lt;/span&gt; PATH_FILE &lt;span style=&quot;color&amp;#58;#006080&quot;&gt;&amp;quot;/tmp/test&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#define&lt;/span&gt; PATH_TTY &lt;span style=&quot;color&amp;#58;#006080&quot;&gt;&amp;quot;/dev/tty&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#define&lt;/span&gt; SHOW_NUM 20&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; main(&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; argc,&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt;* argv[])&amp;#123;&lt;br /&gt;    &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; firstfd,secondfd,thirdfd,ttyfd,n_chars;&lt;br /&gt;    &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt; showrow[SHOW_NUM];&lt;br /&gt;    &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;char&lt;/span&gt; writrow[]=&amp;#123;&lt;span style=&quot;color&amp;#58;#006080&quot;&gt;&amp;quot;testing 123...&amp;quot;&lt;/span&gt;&amp;#125;;&lt;br /&gt;&lt;br /&gt;    &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;((firstfd=open(PATH_FILE,O_RDONLY))==-1)&amp;#123;&lt;br /&gt;        perror(PATH_FILE);&lt;br /&gt;        exit(1);&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;((secondfd=open(PATH_FILE,O_WRONLY))==-1)&amp;#123;&lt;br /&gt;        perror(PATH_FILE);&lt;br /&gt;        exit(1);&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;((thirdfd=open(PATH_FILE,O_RDONLY))==-1)&amp;#123;&lt;br /&gt;        perror(PATH_FILE);&lt;br /&gt;        exit(1);&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;((ttyfd=open(PATH_TTY,O_RDWR))==-1)&amp;#123;&lt;br /&gt;        perror(PATH_FILE);&lt;br /&gt;        exit(1);&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    n_chars=read(firstfd,&amp;amp;showrow,SHOW_NUM);&lt;br /&gt;    printf(&lt;span style=&quot;color&amp;#58;#006080&quot;&gt;&amp;quot;Read 20 chars from test file... \n&amp;quot;&lt;/span&gt;);&lt;br /&gt;    &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(write(ttyfd,&amp;amp;showrow,SHOW_NUM)!=n_chars)&amp;#123;&lt;br /&gt;        fprintf(stderr,&lt;span style=&quot;color&amp;#58;#006080&quot;&gt;&amp;quot;Error&amp;#58;Write error to&amp;quot;&lt;/span&gt;);&lt;br /&gt;        perror(PATH_TTY);&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    printf(&lt;span style=&quot;color&amp;#58;#006080&quot;&gt;&amp;quot;\nWrite chars to test file... \n&amp;quot;&lt;/span&gt;);&lt;br /&gt;    &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(write(secondfd,&amp;amp;writrow,&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;sizeof&lt;/span&gt;(writrow))!=&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;sizeof&lt;/span&gt;(writrow))&amp;#123;&lt;br /&gt;        fprintf(stderr,&lt;span style=&quot;color&amp;#58;#006080&quot;&gt;&amp;quot;Error&amp;#58;Write error to&amp;quot;&lt;/span&gt;);&lt;br /&gt;        perror(PATH_FILE);&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    printf(&lt;span style=&quot;color&amp;#58;#006080&quot;&gt;&amp;quot;Read 20 chars from test file... \n&amp;quot;&lt;/span&gt;);&lt;br /&gt;    n_chars=read(thirdfd,&amp;amp;showrow,SHOW_NUM);&lt;br /&gt;    &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(write(ttyfd,&amp;amp;showrow,SHOW_NUM)!=n_chars)&amp;#123;&lt;br /&gt;        fprintf(stderr,&lt;span style=&quot;color&amp;#58;#006080&quot;&gt;&amp;quot;Error&amp;#58;Write error to&amp;quot;&lt;/span&gt;);&lt;br /&gt;        perror(PATH_TTY);&lt;br /&gt;    &amp;#125;&lt;br /&gt;    printf(&lt;span style=&quot;color&amp;#58;#006080&quot;&gt;&amp;quot;\n&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    close(firstfd);&lt;br /&gt;    close(secondfd);&lt;br /&gt;    close(thirdfd);&lt;br /&gt;    close(ttyfd);&lt;br /&gt;    exit(0);&lt;br /&gt;&amp;#125;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;    运行结果如下： &lt;br /&gt;Read 20 chars from test file... &lt;br /&gt;(一月 01, 2010 23&amp;#58; &lt;br /&gt;Write chars to test file... &lt;br /&gt;Read 20 chars from test file... &lt;br /&gt;testing 123...0 23&amp;#58;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;2.7 联机帮助man中可以查看关于命令,系统调用,系统设备等帮助信息，如何才能了解man 的使用方法,在你的系统中，man分为几个小节?它们分别是什么?&lt;/div&gt;
&lt;div&gt;      &lt;/div&gt;
&lt;div&gt;      输入命令man man，看到man分为九节：&lt;/div&gt;
&lt;p&gt;       1   Executable programs or shell commands &lt;br /&gt;       2   System calls (functions provided by the kernel) &lt;br /&gt;       3   Library calls (functions within program libraries) &lt;br /&gt;       4   Special files (usually found in /dev) &lt;br /&gt;       5   File formats and conventions eg /etc/passwd &lt;br /&gt;       6   Games &lt;br /&gt;       7   Miscellaneous (including macro  packages  and  conven- &lt;br /&gt;           tions), e.g. man(7), groff(7) &lt;br /&gt;       8   System administration commands (usually only for root) &lt;br /&gt;       9   Kernel routines [Non standard]&lt;/p&gt;
&lt;p&gt;2.8 &lt;u&gt;本章提到文件 utmp中还包含了一些记录,它们与已登录用户的信息无关，那么它们存放的是什么？各代表什么含义?&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;      参看man utmp.&lt;/p&gt;
&lt;p&gt;2.9 &lt;u&gt;lseek可以将文件指针移动文件的末尾以后，如&amp;#58; &lt;br /&gt;lseek(fd,100,SEEK_END) &lt;br /&gt;将指针移动文件末尾再往后100个字节的地方。如果从文件末尾以后100个字符的地方开始读会出现什么情况。如果从文件末尾以后100个字符的地方开始写会出现什么情况？从100字节增加到20000字符，再写入&amp;quot;hello&amp;quot;看看会有什么结果,用ls -l来检查文件的长度，再用ls -s试试.&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;     将指针移动文件末尾再往后100个字节的地方。如果 从文件末尾以后100个字符的地方开始读会出现读失败的情况. &lt;br /&gt;     从100个字符的地方开始写会出现,在100个字符之后写入新的字符情况.如指针移 动100个字符，再写入100个字符，就是文件大小增加100,又增加写入的100个字符,共200个字符. &lt;br /&gt;     从100个字节增加到20000字符，再写入hello，用ls -l 检查,文件大小为20005个字节。用cat打印文件，只打印出hello字样. &lt;br /&gt;用ls -s查看，返回4,只由用4个block的大小.&lt;/p&gt;
&lt;div&gt;            &lt;br /&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;display&amp;#58;none&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;display&amp;#58;none&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre&gt; &lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;p&gt; &lt;font face=&quot;宋体&quot; size=&quot;2&quot;&gt;                                                                                   &lt;/font&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/414071396/knightsgang/feedsky/s.gif?r=http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!165.entry&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/knightsgang/414071396/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/knightsgang/414071396/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>Linux</category><pubDate>Mon, 08 Feb 2010 20:30:59 +0800</pubDate><comments>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!165.entry#comment</comments><guid isPermaLink="false">5536415C9770F9BF!165</guid><fs:srclink>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!165.entry</fs:srclink><fs:srcfeed>http://cid-5536415c9770f9bf.users.api.live.net/Users(6140167007899810239)/Main?$format=rss20</fs:srcfeed><fs:itemid>feedsky/knightsgang/~7720050/414071396/5829218</fs:itemid></item><item><title>基于链接法的散列表的c++实现</title><link>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!157.entry</link><slash:comments>0</slash:comments><live:type>blogentry</live:type><live:typelabel>Blog Entry</live:typelabel><wfw:commentRss>http://cid-5536415c9770f9bf.users.api.live.net:80/Users(6140167007899810239)/Blogs('5536415C9770F9BF!119')/Entries('5536415C9770F9BF!157')/Comments?$format=application%2frss%2bxml</wfw:commentRss><dcterms:modified>2009-07-31T12:56:50.9800000Z</dcterms:modified><description>&lt;p&gt;      我们知道,散列表解决冲突的时候分为开散列和闭散列两种方法.其中,开散列其实就是链接法(chaining),而闭散列就是开放寻址法(open addressing).开放寻址法根据寻找下一个桶的方法分为线性探查法(linear probing)、二次探查法(quadratic probing)、双散列法.这些方法的性能如下图所示&amp;#58;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https&amp;#58;//z8acwq.bay.livefilestore.com/y1mNMIo4WBIUeqheYNFYtZdssNHnGqwlWYbbwXxr7To7qzQLhXtUADUiFSv27qM7JGco10iJdW25hm6aJD4f1oaYKPtlZ1_TrtYyqICdRPqp-YN4wDu-9Nz736yYFNfg-pytYC8BfA8sf-FTFnfMyIl2w/%E6%90%9C%E7%B4%A2%E6%88%90%E5%8A%9F[5].jpg&quot; rel=&quot;WLPP&quot;&gt;&lt;img title=&quot;搜索成功&quot; style=&quot;border-top-width&amp;#58;0px;display&amp;#58;inline;border-left-width&amp;#58;0px;border-bottom-width&amp;#58;0px;border-right-width&amp;#58;0px&quot; height=&quot;335&quot; alt=&quot;搜索成功&quot; src=&quot;https&amp;#58;//z8acwq.bay.livefilestore.com/y1mw1wK7Dqbrqi5dQBeEapA_ZkQU94uge36eY6nIHrMVkuKcSx20OzTpeqwShJpZUHkbQVinUQrA4eN6kUxech1fut913G-_Q5PuYACfDIPndqQQ3NzUct1SGe4o9-MIfms-7zdjfnogJ_5bcKcxrAD8Q/%E6%90%9C%E7%B4%A2%E6%88%90%E5%8A%9F_thumb[3].jpg&quot; width=&quot;447&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https&amp;#58;//z8acwq.bay.livefilestore.com/y1mpHYCn7wMEWv3HdkzalTPgjTdaITkyWRsZceaxL94jiPnzEc3Wrus6gJg1LH-qQKKu2FsiX6YsOUlglWx9mVLfcg_bR1o5-WrbUiRLTIc1UMnutejTb8mbuEnVV2nmnN5mgvbYTuAWCNDLQng76YTCg/%E6%90%9C%E7%B4%A2%E4%B8%8D%E6%88%90%E5%8A%9F[3].jpg&quot; rel=&quot;WLPP&quot;&gt;&lt;img title=&quot;搜索不成功&quot; style=&quot;border-top-width&amp;#58;0px;display&amp;#58;inline;border-left-width&amp;#58;0px;border-bottom-width&amp;#58;0px;border-right-width&amp;#58;0px&quot; height=&quot;337&quot; alt=&quot;搜索不成功&quot; src=&quot;https&amp;#58;//z8acwq.bay.livefilestore.com/y1mWV5Cilax5c9Pqm7qQlNxFNakBszDQCKlzFBzZqjpdKjApHI4ZwlpzhwiQPMoM0qJyMEggbBiGICmUgrgp62LojryLQBNHr2h9s8TWS_9cyXeMsGZYGgI83B_c3781sP8qwZLJIFzJlpjoZnPy7kDlw/%E6%90%9C%E7%B4%A2%E4%B8%8D%E6%88%90%E5%8A%9F_thumb[1].jpg&quot; width=&quot;448&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;可以看出,链接法的性能十分理想.以下即为基于链接法的散列表的模版类,其中仅仅包含了Insert,Search,Delete三个操作&amp;#58;&lt;/p&gt; &lt;div style=&quot;border-right&amp;#58;silver 1px solid;padding-right&amp;#58;4px;border-top&amp;#58;silver 1px solid;padding-left&amp;#58;4px;font-size&amp;#58;8pt;padding-bottom&amp;#58;4px;margin&amp;#58;20px 0px 10px;overflow&amp;#58;auto;border-left&amp;#58;silver 1px solid;width&amp;#58;97.5%;cursor&amp;#58;text;direction&amp;#58;ltr;line-height&amp;#58;12pt;padding-top&amp;#58;4px;border-bottom&amp;#58;silver 1px solid;font-family&amp;#58;'Courier New', courier, monospace;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left&quot;&gt; &lt;div style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   1&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; hash(&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; key)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   2&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt; key%7;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   3&amp;#58;&lt;/span&gt; &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   4&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   5&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;template&lt;/span&gt;&amp;lt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;class&lt;/span&gt; E,&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;class&lt;/span&gt; K &amp;gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   6&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;struct&lt;/span&gt; HashNode&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   7&amp;#58;&lt;/span&gt;     E ele;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   8&amp;#58;&lt;/span&gt;     K key;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   9&amp;#58;&lt;/span&gt;     HashNode&amp;lt;E,K&amp;gt;* link;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  10&amp;#58;&lt;/span&gt;     HashNode(HashNode&amp;lt;E,K&amp;gt;* ptr=NULL) &amp;#123;link=ptr;&amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  11&amp;#58;&lt;/span&gt;     HashNode(&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;const&lt;/span&gt; E&amp;amp; e1,K k1,HashNode&amp;lt;E,K&amp;gt;* ptr=NULL)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  12&amp;#58;&lt;/span&gt;         ele=e1; key=k1; link=ptr;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  13&amp;#58;&lt;/span&gt;     &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  14&amp;#58;&lt;/span&gt; &amp;#125;;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  15&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  16&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  17&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;template&lt;/span&gt;&amp;lt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;class&lt;/span&gt; E,&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;class&lt;/span&gt; K&amp;gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  18&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;class&lt;/span&gt; ChainedHash&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  19&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;public&lt;/span&gt;&amp;#58;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  20&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;void&lt;/span&gt; Init(&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; s)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  21&amp;#58;&lt;/span&gt;             Size=s; &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  22&amp;#58;&lt;/span&gt;             HNArray=&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;new&lt;/span&gt; HashNode&amp;lt;E,K&amp;gt;* [Size];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  23&amp;#58;&lt;/span&gt;             &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; i=0;i&amp;lt;Size;i++) &amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  24&amp;#58;&lt;/span&gt;                 HNArray[i]=&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;new&lt;/span&gt; HashNode&amp;lt;E,K&amp;gt;(NULL);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  25&amp;#58;&lt;/span&gt;                &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  26&amp;#58;&lt;/span&gt;             &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  27&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;bool&lt;/span&gt; Insert(E&amp;amp; e1,K k1);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  28&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;bool&lt;/span&gt; Search(E&amp;amp; e1,K k1);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  29&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;bool&lt;/span&gt; Delete(E&amp;amp; e1,K k1);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  30&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;protected&lt;/span&gt;&amp;#58;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  31&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; Size;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  32&amp;#58;&lt;/span&gt;         HashNode&amp;lt;E,K&amp;gt;* * HNArray; &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  33&amp;#58;&lt;/span&gt; &amp;#125;;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  34&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  35&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;class&lt;/span&gt; E,&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;class&lt;/span&gt; K&amp;gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  36&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;bool&lt;/span&gt; ChainedHash&amp;lt;E,K&amp;gt;&amp;#58;&amp;#58;Insert(E&amp;amp; e1,K k1)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  37&amp;#58;&lt;/span&gt;     HashNode&amp;lt;E,K&amp;gt;* p=&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;new&lt;/span&gt; HashNode&amp;lt;E,K&amp;gt;(e1,k1,NULL);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  38&amp;#58;&lt;/span&gt;     HashNode&amp;lt;E,K&amp;gt;* temp=HNArray[hash(k1)]; &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  39&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(temp-&amp;gt;link==NULL)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  40&amp;#58;&lt;/span&gt;         temp-&amp;gt;link=p; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;delete&lt;/span&gt; temp; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt; true;&amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  41&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(temp-&amp;gt;link!=NULL)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  42&amp;#58;&lt;/span&gt;         p-&amp;gt;link=temp-&amp;gt;link; temp-&amp;gt;link=p; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;delete&lt;/span&gt; temp; &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  43&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt; true;&amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  44&amp;#58;&lt;/span&gt; &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  45&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  46&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;template&lt;/span&gt;&amp;lt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;class&lt;/span&gt; E,&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;class&lt;/span&gt; K&amp;gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  47&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;bool&lt;/span&gt; ChainedHash&amp;lt;E,K&amp;gt;&amp;#58;&amp;#58;Search(E&amp;amp; e1,K k1)&amp;#123; &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  48&amp;#58;&lt;/span&gt;     HashNode&amp;lt;E,K&amp;gt;* temp=HNArray[hash(k1)];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  49&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;while&lt;/span&gt;(temp!=NULL)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  50&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(temp-&amp;gt;key==k1) &amp;#123;e1=temp-&amp;gt;ele; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt; true;&amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  51&amp;#58;&lt;/span&gt;             &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;else&lt;/span&gt; temp=temp-&amp;gt;link;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  52&amp;#58;&lt;/span&gt;     &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  53&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt; false;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  54&amp;#58;&lt;/span&gt; &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  55&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  56&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;template&lt;/span&gt;&amp;lt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;class&lt;/span&gt; E,&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;class&lt;/span&gt; K&amp;gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  57&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;bool&lt;/span&gt; ChainedHash&amp;lt;E,K&amp;gt;&amp;#58;&amp;#58;Delete(E&amp;amp; e1,K k1)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  58&amp;#58;&lt;/span&gt;     HashNode&amp;lt;E,K&amp;gt;* temp=HNArray[hash(k1)];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  59&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;while&lt;/span&gt;(temp!=NULL)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  60&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(temp-&amp;gt;link-&amp;gt;key==k1) &amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  61&amp;#58;&lt;/span&gt;             e1=temp-&amp;gt;link-&amp;gt;ele; &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  62&amp;#58;&lt;/span&gt;             HashNode&amp;lt;E,K&amp;gt;* p=temp-&amp;gt;link;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  63&amp;#58;&lt;/span&gt;             temp-&amp;gt;link=p-&amp;gt;link; &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  64&amp;#58;&lt;/span&gt;             p-&amp;gt;link=NULL;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  65&amp;#58;&lt;/span&gt;             &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;delete&lt;/span&gt; p;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  66&amp;#58;&lt;/span&gt;                 &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt; true;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  67&amp;#58;&lt;/span&gt;         &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  68&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;else&lt;/span&gt; temp=temp-&amp;gt;link;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  69&amp;#58;&lt;/span&gt;     &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  70&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt; false;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  71&amp;#58;&lt;/span&gt; &amp;#125;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/414071397/knightsgang/feedsky/s.gif?r=http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!157.entry&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/knightsgang/414071397/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/knightsgang/414071397/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>Algorithm</category><pubDate>Fri, 31 Jul 2009 20:56:50 +0800</pubDate><comments>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!157.entry#comment</comments><guid isPermaLink="false">5536415C9770F9BF!157</guid><fs:srclink>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!157.entry</fs:srclink><fs:srcfeed>http://cid-5536415c9770f9bf.users.api.live.net/Users(6140167007899810239)/Main?$format=rss20</fs:srcfeed><fs:itemid>feedsky/knightsgang/~7720050/414071397/5829218</fs:itemid></item><item><title>Windows下安装GCC4.4.0</title><link>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!149.entry</link><slash:comments>0</slash:comments><live:type>blogentry</live:type><live:typelabel>Blog Entry</live:typelabel><wfw:commentRss>http://cid-5536415c9770f9bf.users.api.live.net:80/Users(6140167007899810239)/Blogs('5536415C9770F9BF!119')/Entries('5536415C9770F9BF!149')/Comments?$format=application%2frss%2bxml</wfw:commentRss><dcterms:modified>2009-07-25T03:53:21.4930000Z</dcterms:modified><description>&lt;p&gt;      在POJ1002的AC过程中,经历了数次的RE,郁闷不已.百思不得其解的时候,换了个台州大学的JO系统,一次提交就AC了,我就更加不解了.郁闷中忽然想起,北大的系统g++的版本是4.4.0,而我本地用的是3.4.5,于是回POJ把编译器换成C++,一次通过.随后,我试图查询台大的G++版本,但没有成功.&lt;/p&gt; &lt;p&gt;      无论如何,编译器的版本,已经影响到我的ACM之路了,于是下定决心升级GCC.其实我在两个月前就试图升级,但没有成功.找到这篇博客&amp;#58;  &lt;a href=&quot;http&amp;#58;//hi.baidu.com/lindily/blog/item/44c403b3ac992aaed8335a38.html&quot;&gt;（原创）安装GCC4.4攻略(带MinGW)&lt;/a&gt;,按照上面的提示,经过繁复的下载,解压后终于得到一个mingw文件夹,没有添加path,兴奋地测试了Hello World!程序,但是系统却提示&amp;quot;没有找到libgcc_s_dw2-1.dll组件&amp;quot;,又是一段时间的郁闷.&lt;/p&gt; &lt;p&gt;      在郁闷中继续寻找解决方案,在上面那篇博客中发现提到了什么tdm’s gcc/mingw,于是到网站&lt;a href=&quot;http&amp;#58;//www.tdragon.net/&quot;&gt;Twilight Dragon Media&lt;/a&gt;,总算找到了一个好东西&lt;a href=&quot;http&amp;#58;//sourceforge.net/projects/tdm-gcc/files/TDM_MinGW Installer/1.905.0/tdm-mingw-1.905.0-webdl.exe/download&quot;&gt;tdm-mingw-1.905.0-webdl.exe&lt;/a&gt;.这是一个类似于mingw-5.1.3.exe的安装程序,我选择了TDM's GCC/ALL Languages的安装选项,注意在选择下载镜像的时候,选择台湾省的NCHC服务器(赞台湾省的高等院校一个,看看台湾同胞为世界的开源事业做的贡献,鄙视一下大陆的高等院校的奉献观念),速度很快,一路next完,等待程序的自动下载,安装.安装完成后,迫不及待的在run了一遍Hello World!程序,一切顺利.&lt;/p&gt; &lt;p&gt;     不过,等到我拿原来在3.4.5下编译通过的1002的代码在4.4.0下编译时,居然也顺利通过,但是放到POJ上,依然提示RE,估计是POJ的G++系统设置有错误,这就是我无法解决的了.&lt;/p&gt; &lt;p&gt;      以下是我安装GCC4.4.0的总结&amp;#58;&lt;/p&gt; &lt;p&gt;      1.Mingw-5.1.4.exe可以顺利安装GCC3.4.5,无法安装GCC4.4.0,但是3.4.5还是比较稳定的版本,有许多来不及升级到4.4.0的JO系统还在使用这一版本,因此兼容性有保证.&lt;/p&gt; &lt;p&gt;      2.手动安装的官方GCC4.4.0可以编译源文件,但是需要注意编译命令有所改变,原来的 g++ –g example.cpp –o example的命令会生成一个较3.4.5下的相同命令大的多的可执行程序(Hello World!经4.4.0编译可以达到3.9M,但在3.4.5下相同的命令只有400K),如果想要减小可执行程序的体积,要用 g++ –s example.cpp –o example,可以达到与3.4.5下的-g命令相同的效果,但是注意以上两个命令都是动态链接库,如果生成的可执行程序的文件夹中不包含libgcc_s_dw2-1.dll,会无法运行程序,解决问题的方法是在原有的命令后添加-static是的编译时选择静态链接.&lt;/p&gt; &lt;p&gt;      3.TDM's GCC由于是第三方编译,因此在使用感受上与由Mingw-5.1.4.exe安装的官方GCC3.4.5版本一模一样,可以说是最佳选择.&lt;/p&gt; &lt;p&gt;      4.刚刚才发现GCC4.4.1竟然已经发布了,追逐技术的脚步有时是一件费力又不讨好的事,目前还不值得为0.0.1的升级去折腾,不过回望过去,GCC4.4.0是4月22日发布,而TDM's GCC4.4.0是5月1日发布,就是说过十天左右,TDM将发布相应的版本,到时再下不迟.&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/414071398/knightsgang/feedsky/s.gif?r=http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!149.entry&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/knightsgang/414071398/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/knightsgang/414071398/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>C++</category><pubDate>Sat, 25 Jul 2009 11:53:21 +0800</pubDate><comments>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!149.entry#comment</comments><guid isPermaLink="false">5536415C9770F9BF!149</guid><fs:srclink>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!149.entry</fs:srclink><fs:srcfeed>http://cid-5536415c9770f9bf.users.api.live.net/Users(6140167007899810239)/Main?$format=rss20</fs:srcfeed><fs:itemid>feedsky/knightsgang/~7720050/414071398/5829218</fs:itemid></item><item><title>POJ1442解题报告</title><link>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!147.entry</link><slash:comments>0</slash:comments><live:type>blogentry</live:type><live:typelabel>Blog Entry</live:typelabel><wfw:commentRss>http://cid-5536415c9770f9bf.users.api.live.net:80/Users(6140167007899810239)/Blogs('5536415C9770F9BF!119')/Entries('5536415C9770F9BF!147')/Comments?$format=application%2frss%2bxml</wfw:commentRss><dcterms:modified>2009-07-23T15:02:58.4600000Z</dcterms:modified><description>&lt;p&gt;      近日看了CLRS的不朽巨著&amp;lt;算法导论&amp;gt;的第六章,冲动地想立刻实现.于是,拿起键盘一蹴而就,写完堆的代码,g++竟然一遍通过.不得不佩服的CLRS的言简意赅,书上代码的简洁通用.当然,简洁的代码可能在健壮性上有所欠缺,但是对于具体的问题却是又好又快的解决方案.因此,CLRS的 &amp;lt;算法导论&amp;gt;尤其适合用来做ACM的题目.&lt;/p&gt; &lt;p&gt;      实现完堆以后,总觉得终究需要习题的磨练,于是上POJ上找寻用堆来做的题目,找到了1442 Black Box 问题.用了将近一刻钟读懂题目,题目还是很好理解的,测试数据将一个数组的数据依次给出,在其中某个时刻要求你给出当前所有已给的数据中按从小到大排排在第i位的数据.思路还是很快可以形成的&amp;#58;每次用插入排序将所有已给的数据排序.但这样一个很大的问题就是,插入排序在交换数组数据的位置时浪费了太多的时间,必然会 TLE.堆排序也同样会遭遇这样的处境,解决问题的关键在于,&lt;font color=&quot;#ff0000&quot;&gt;&lt;strong&gt;为什么一定要给数据排序,现在我们只需要给出第i个大的数就行了,我们可以把数据前i-1个较小的&amp;quot;删掉&amp;quot;,那第i大的数就成了最小的数,或者我们把后n-i个较大的删掉,那第i大的数就成了最大的数.&lt;/strong&gt;&lt;/font&gt;最最方便的数据结构就是由堆进化而来又比堆应用广泛得多的优先级队列,其实上述第一个方案描述的是最小优先级队列,第二个方案描述的是最大优先级队列.优先级队列每一次能够在O(lgn)的时间里给出最大的数据.&lt;/p&gt; &lt;p&gt;      有了上述的准备,代码就好写的多了&amp;#58;&lt;/p&gt; &lt;p&gt;        1.应用了STL的priority_queue结构,用了500ms的时间解决问题.&lt;/p&gt; &lt;div style=&quot;border-right&amp;#58;silver 1px solid;padding-right&amp;#58;4px;border-top&amp;#58;silver 1px solid;padding-left&amp;#58;4px;font-size&amp;#58;8pt;padding-bottom&amp;#58;4px;margin&amp;#58;20px 0px 10px;overflow&amp;#58;auto;border-left&amp;#58;silver 1px solid;width&amp;#58;97.5%;cursor&amp;#58;text;direction&amp;#58;ltr;line-height&amp;#58;12pt;padding-top&amp;#58;4px;border-bottom&amp;#58;silver 1px solid;font-family&amp;#58;'Courier New', courier, monospace;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left&quot;&gt; &lt;div style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   1&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   2&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#include&lt;/span&gt; &amp;lt;queue&amp;gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   3&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#include&lt;/span&gt; &amp;lt;algorithm&amp;gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   4&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;namespace&lt;/span&gt; std;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   5&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   6&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; M,N,c[30002],p[30002],i,j,value;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   7&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   8&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; main()&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   9&amp;#58;&lt;/span&gt;     cin&amp;gt;&amp;gt;M&amp;gt;&amp;gt;N;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  10&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;for&lt;/span&gt;(i=1;i&amp;lt;=M;i++)&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  11&amp;#58;&lt;/span&gt;         cin&amp;gt;&amp;gt;c[i];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  12&amp;#58;&lt;/span&gt;     p[0]=0;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  13&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;for&lt;/span&gt;(i=1;i&amp;lt;=N;i++)&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  14&amp;#58;&lt;/span&gt;         cin&amp;gt;&amp;gt;p[i];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  15&amp;#58;&lt;/span&gt;     priority_queue &amp;lt;&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt;&amp;gt; a,b;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  16&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;for&lt;/span&gt;(i=1;i&amp;lt;=N;i++)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  17&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;for&lt;/span&gt;(j=p[i-1]+1;j&amp;lt;=p[i];j++)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  18&amp;#58;&lt;/span&gt;             a.push(c[j]);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  19&amp;#58;&lt;/span&gt;             &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(a.size()&amp;gt;i-1)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  20&amp;#58;&lt;/span&gt;                 value=-a.top();&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  21&amp;#58;&lt;/span&gt;                 a.pop();&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  22&amp;#58;&lt;/span&gt;                 b.push(value);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  23&amp;#58;&lt;/span&gt;             &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  24&amp;#58;&lt;/span&gt;         &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  25&amp;#58;&lt;/span&gt;         value=-b.top();&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  26&amp;#58;&lt;/span&gt;         b.pop();&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  27&amp;#58;&lt;/span&gt;         a.push(value);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  28&amp;#58;&lt;/span&gt;         cout&amp;lt;&amp;lt;a.top()&amp;lt;&amp;lt;endl;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  29&amp;#58;&lt;/span&gt;     &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  30&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt; 0;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  31&amp;#58;&lt;/span&gt; &amp;#125;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;       2.自己动手写了个priority_queue的代码,具体算法与1中一模一样,用了440ms的时间解决问题.&lt;/p&gt;
&lt;div style=&quot;border-right&amp;#58;silver 1px solid;padding-right&amp;#58;4px;border-top&amp;#58;silver 1px solid;padding-left&amp;#58;4px;font-size&amp;#58;8pt;padding-bottom&amp;#58;4px;margin&amp;#58;20px 0px 10px;overflow&amp;#58;auto;border-left&amp;#58;silver 1px solid;width&amp;#58;97.5%;cursor&amp;#58;text;direction&amp;#58;ltr;line-height&amp;#58;12pt;padding-top&amp;#58;4px;border-bottom&amp;#58;silver 1px solid;font-family&amp;#58;'Courier New', courier, monospace;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left&quot;&gt;
&lt;div style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   1&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   2&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;namespace&lt;/span&gt; std;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   3&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   4&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#define&lt;/span&gt; Parent(i) ((i-1)/2)&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   5&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#define&lt;/span&gt; Left(i)   (2*i+1)&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   6&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#cc6633&quot;&gt;#define&lt;/span&gt; Right(i)  (2*i+2)&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   7&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   8&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;void&lt;/span&gt; Max_Heapify(&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; A[],&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; i,&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt;&amp;amp; H_Size)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;   9&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; l=Left(i),r=Right(i),largest;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  10&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(l&amp;lt;=H_Size &amp;amp;&amp;amp; A[l]&amp;gt;A[i])&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  11&amp;#58;&lt;/span&gt;         largest=l;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  12&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;else&lt;/span&gt; largest=i;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  13&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(r&amp;lt;=H_Size &amp;amp;&amp;amp; A[r]&amp;gt;A[largest])&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  14&amp;#58;&lt;/span&gt;         largest=r;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  15&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(largest!=i)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  16&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; temp=A[i];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  17&amp;#58;&lt;/span&gt;         A[i]=A[largest];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  18&amp;#58;&lt;/span&gt;         A[largest]=temp;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  19&amp;#58;&lt;/span&gt;         Max_Heapify(A,largest,H_Size);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  20&amp;#58;&lt;/span&gt;     &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  21&amp;#58;&lt;/span&gt; &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  22&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  23&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; Heap_Maximum(&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; A[])&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  24&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt; A[0];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  25&amp;#58;&lt;/span&gt; &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  26&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  27&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; Heap_Extract_Max(&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; A[],&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt;&amp;amp; H_Size)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  28&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(H_Size&amp;lt;1)&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  29&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt; 1000000;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  30&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; max=A[0];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  31&amp;#58;&lt;/span&gt;     A[0]=A[H_Size-1];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  32&amp;#58;&lt;/span&gt;     H_Size=H_Size-1;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  33&amp;#58;&lt;/span&gt;     Max_Heapify(A,0,H_Size);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  34&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt; max;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  35&amp;#58;&lt;/span&gt; &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  36&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  37&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;void&lt;/span&gt; Heap_Increase_Key(&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; A[],&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; i,&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; key)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  38&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(key&amp;lt;A[i]) &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  39&amp;#58;&lt;/span&gt;     A[i]=key;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  40&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;while&lt;/span&gt;(i&amp;gt;0 &amp;amp;&amp;amp; A[Parent(i)]&amp;lt;A[i])&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  41&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; temp;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  42&amp;#58;&lt;/span&gt;         temp=A[i];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  43&amp;#58;&lt;/span&gt;         A[i]=A[Parent(i)];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  44&amp;#58;&lt;/span&gt;         A[Parent(i)]=temp;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  45&amp;#58;&lt;/span&gt;         i=Parent(i);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  46&amp;#58;&lt;/span&gt;     &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  47&amp;#58;&lt;/span&gt; &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  48&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  49&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;void&lt;/span&gt; Max_Heap_Insert(&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; A[],&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; key,&lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt;&amp;amp; H_Size)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  50&amp;#58;&lt;/span&gt;     H_Size++;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  51&amp;#58;&lt;/span&gt;     A[H_Size-1]=-2000000000;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  52&amp;#58;&lt;/span&gt;     Heap_Increase_Key(A,H_Size-1,key);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  53&amp;#58;&lt;/span&gt; &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  54&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  55&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  56&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; M,N,c[30002],p[30002],i,j,value;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  57&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  58&amp;#58;&lt;/span&gt; &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; main()&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  59&amp;#58;&lt;/span&gt;     cin&amp;gt;&amp;gt;M&amp;gt;&amp;gt;N;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  60&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;for&lt;/span&gt;(i=1;i&amp;lt;=M;i++)&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  61&amp;#58;&lt;/span&gt;         cin&amp;gt;&amp;gt;c[i];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  62&amp;#58;&lt;/span&gt;     p[0]=0;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  63&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;for&lt;/span&gt;(i=1;i&amp;lt;=N;i++)&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  64&amp;#58;&lt;/span&gt;         cin&amp;gt;&amp;gt;p[i];&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  65&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;int&lt;/span&gt; a[30002],b[30002],AH_Size=0,BH_Size=0;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  66&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;for&lt;/span&gt;(i=1;i&amp;lt;=N;i++)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  67&amp;#58;&lt;/span&gt;         &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;for&lt;/span&gt;(j=p[i-1]+1;j&amp;lt;=p[i];j++)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  68&amp;#58;&lt;/span&gt;             Max_Heap_Insert(a,c[j],AH_Size);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  69&amp;#58;&lt;/span&gt;             &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  70&amp;#58;&lt;/span&gt;             &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;if&lt;/span&gt;(AH_Size&amp;gt;i-1)&amp;#123;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  71&amp;#58;&lt;/span&gt;                 value=-Heap_Extract_Max(a,AH_Size);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  72&amp;#58;&lt;/span&gt;                 &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  73&amp;#58;&lt;/span&gt;                 Max_Heap_Insert(b,value,BH_Size);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  74&amp;#58;&lt;/span&gt;             &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  75&amp;#58;&lt;/span&gt;         &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  76&amp;#58;&lt;/span&gt;         value=-Heap_Extract_Max(b,BH_Size);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  77&amp;#58;&lt;/span&gt;         Max_Heap_Insert(a,value,AH_Size);&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  78&amp;#58;&lt;/span&gt;         cout&amp;lt;&amp;lt;Heap_Maximum(a)&amp;lt;&amp;lt;endl;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  79&amp;#58;&lt;/span&gt;     &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  80&amp;#58;&lt;/span&gt;     &lt;span style=&quot;color&amp;#58;#0000ff&quot;&gt;return&lt;/span&gt; 0;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  81&amp;#58;&lt;/span&gt; &amp;#125;&lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;#f4f4f4;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  82&amp;#58;&lt;/span&gt;    &lt;/pre&gt;&lt;pre style=&quot;padding-right&amp;#58;0px;padding-left&amp;#58;0px;font-size&amp;#58;8pt;padding-bottom&amp;#58;0px;margin&amp;#58;0em;overflow&amp;#58;visible;width&amp;#58;100%;color&amp;#58;black;direction&amp;#58;ltr;border-top-style&amp;#58;none;line-height&amp;#58;12pt;padding-top&amp;#58;0px;font-family&amp;#58;'Courier New', courier, monospace;border-right-style&amp;#58;none;border-left-style&amp;#58;none;background-color&amp;#58;white;text-align&amp;#58;left;border-bottom-style&amp;#58;none&quot;&gt;&lt;span style=&quot;color&amp;#58;#606060&quot;&gt;  83&amp;#58;&lt;/span&gt;  &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;在这道题目的AC过程中,还是有几点感悟的&amp;#58;&lt;/p&gt;
&lt;p&gt;   1.STL可能会使你的代码变得相当的简洁,但是在空间和时间上必然会造成一定的损失,尤其是在空间上的损失在有些情况下是非常可怕的事,比如将来做单片机的开发,你会发现以字节来计算的空间是如此的宝贵.STL当然很强大,但是在大多数情况下我们并不需要STL的所有功能,我们需要为STL那些对问题没用的代码付出巨大的空间的代价吗?&lt;/p&gt;
&lt;p&gt;   2.在北大的grid的JudgeOnline系统上,我的第二段代码居然得到了TLE的结果,而在南开的JO上更是竟然得到了WA的结果,最后还是在天大的JO上AC过了,赞天津大学一个.&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/414071399/knightsgang/feedsky/s.gif?r=http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!147.entry&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/knightsgang/414071399/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/knightsgang/414071399/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><pubDate>Thu, 23 Jul 2009 23:02:58 +0800</pubDate><comments>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!147.entry#comment</comments><guid isPermaLink="false">5536415C9770F9BF!147</guid><fs:srclink>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!147.entry</fs:srclink><fs:srcfeed>http://cid-5536415c9770f9bf.users.api.live.net/Users(6140167007899810239)/Main?$format=rss20</fs:srcfeed><fs:itemid>feedsky/knightsgang/~7720050/414071399/5829218</fs:itemid></item><item><title>位图的应用</title><link>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!144.entry</link><slash:comments>0</slash:comments><live:type>blogentry</live:type><live:typelabel>Blog Entry</live:typelabel><wfw:commentRss>http://cid-5536415c9770f9bf.users.api.live.net:80/Users(6140167007899810239)/Blogs('5536415C9770F9BF!119')/Entries('5536415C9770F9BF!144')/Comments?$format=application%2frss%2bxml</wfw:commentRss><dcterms:modified>2009-07-10T03:47:05.8670000Z</dcterms:modified><description>&lt;p&gt;编程珠玑 Chapter1&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;em&gt;位图&lt;/em&gt;&lt;/strong&gt;或&lt;em&gt;&lt;strong&gt;位向量图&lt;/strong&gt;作为一个集合，&lt;/em&gt;表示的这样的一个数据结构：&lt;/p&gt; &lt;p&gt;          用字符串 0 1 1 1 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 表示集合 &amp;#123;1,2,3,5,8,13&amp;#125;.&lt;/p&gt; &lt;p&gt;    &lt;strong&gt;位图&lt;/strong&gt;的应用需要数据有如下的特性&amp;#58;&lt;/p&gt; &lt;p&gt;         1.输入数据限制在相对较小的范围内;&lt;/p&gt; &lt;p&gt;         2.数据没有重复;&lt;/p&gt; &lt;p&gt;         3.除了单一整数外,没有任何其他关联数据.&lt;/p&gt; &lt;p&gt;    但很可惜的是,大多数待排序数据没有这些特性(就是说这些特性在大多数情况下是很难满足的).&lt;/p&gt; &lt;p&gt;习题1 如果不缺内存，如何使用一个具有库的语言来实现一种排序算法以表示和排序集合&lt;/p&gt; &lt;p&gt;解题报告&amp;#58;&lt;/p&gt; &lt;p&gt;拥有库的语言,C/C++/JAVA都是很好的选择,由于目前只会C++,因此对于我来说别无选择. 而对于C++,实现排序的库有太多的选择,典型的有STL中的stdlib.h中的qsort和algorithm中的sort.对于这两者的区别,在这里不想多谈(其实我并不清楚,大概了解的是stdlib是C的产物,而algorithm的后代,不过,sort在使用上比较简单).&lt;/p&gt; &lt;p&gt;#include &amp;lt;algorithm&amp;gt;&lt;/p&gt; &lt;p&gt;#include &amp;lt;iostream&amp;gt;&lt;/p&gt; &lt;p&gt;#include &amp;lt;vector&amp;gt;&lt;/p&gt; &lt;p&gt;using namespace std;&lt;/p&gt; &lt;p&gt;int main()&amp;#123;&lt;/p&gt; &lt;p&gt;vector&amp;lt;int&amp;gt; a;&lt;/p&gt; &lt;p&gt;for(int i=0;i&amp;lt;=5;i++) a.push_back(i-5);&lt;/p&gt; &lt;p&gt;sort(a.begin(),a.end());&lt;/p&gt; &lt;p&gt;for(int i=0;i&amp;lt;5;i++) cout&amp;lt;&amp;lt;a[i]&amp;lt;&amp;lt;' ';&lt;/p&gt; &lt;p&gt;return 0;&lt;/p&gt; &lt;p&gt;&amp;#125;&lt;/p&gt; &lt;p&gt;习题二 如何使用位逻辑运算（例如与、或、移位）来实现位向量&lt;/p&gt; &lt;p&gt;解题报告：&lt;/p&gt; &lt;p&gt;一开始当然没有想到要用位逻辑运算来实现位向量，而是用十进制来实现（这是理所当然的事）。&lt;/p&gt; &lt;p&gt;用一个一维数组a[10000000]来存储至多1E7个号码，考虑整数m,一旦发现这个号码，根据我们的算法，应当置a[m]=1.&lt;/p&gt; &lt;p&gt;好的，一切看起来都如此完美，简单的算法，出色的时间效率，差强人意的空间效率.但上机起来就不是这回事了&amp;#58;&lt;/p&gt; &lt;p&gt;#include &amp;lt;fstream&amp;gt;&lt;/p&gt; &lt;p&gt;#include &amp;lt;iostream&amp;gt;&lt;/p&gt; &lt;p&gt;using namespace std;&lt;/p&gt; &lt;p&gt;int main()&amp;#123;&lt;/p&gt; &lt;p&gt;ifstream in;&lt;/p&gt; &lt;p&gt;ofstream outt;&lt;/p&gt; &lt;p&gt;in.open(&amp;quot;c&amp;#58;/project/out.txt&amp;quot;);&lt;/p&gt; &lt;p&gt;outt.open(&amp;quot;c&amp;#58;/project/outt.txt&amp;quot;);&lt;/p&gt; &lt;p&gt;bool a[10000000];&lt;/p&gt; &lt;p&gt;for(int i=0;i&amp;lt;10000000;i++) a[i]=false;&lt;/p&gt; &lt;p&gt;int m;&lt;/p&gt; &lt;p&gt;for(int i=0;i&amp;lt;1000000;i++) &lt;/p&gt; &lt;p&gt;&amp;#123;in&amp;gt;&amp;gt;m; a[m]=true;&amp;#125;&lt;/p&gt; &lt;p&gt;for(int i=0;i&amp;lt;10000000;i++) &lt;/p&gt; &lt;p&gt;if(a[m]==true) outt&amp;lt;&amp;lt;m&amp;lt;&amp;lt;endl;&lt;/p&gt; &lt;p&gt;in.close();&lt;/p&gt; &lt;p&gt;outt.close();&lt;/p&gt; &lt;p&gt;return 0;&lt;/p&gt; &lt;p&gt;&amp;#125;&lt;/p&gt; &lt;p&gt;但是美好的想法在现实面前是如此的脆弱,这段代码在运行的时候出错了,原因是数组越界.好吧,现在我可以承认,数组开到1E7是不现实的,这该如何是好?&lt;/p&gt; &lt;p&gt;现在是时候回到位逻辑运算了,这是一种模仿计算机底层二进制运算的运算方法,十分高效,但是第一次看上去会显得晦涩难懂,等到将它与十进制运算联系起来后,会发现它相当有用. &lt;/p&gt; &lt;p&gt;整个的思想是,a[10000000]显得太过巨大的原因是每一个元素a[i]只保留了一个bool值或者是一个整型值0或1,如果我们把每一个元素包含的内容扩充,使之保留尽可能多的号码是否存在的信息,那么数组范围会得到明显的下降.&lt;/p&gt; &lt;p&gt;事实上,我们是用每一个元素表示一个32位的二进制字符串,这样这个元素可以保留相邻32个号码是否存在的信息,数组范围就下降到10000000/32了.例如对于号码89256,由于89256 mod 32=2789…8,这样我们应该置a[2789]中32位字符串的第8位(从低位数起)为1.&lt;/p&gt; &lt;p&gt;现在问题的关键是,如何用位逻辑运算来表示这种操作. 关于位逻辑运算的知识,你应当去参考手头的C++教材,因为在这里我无法讲的比教材更好&amp;#58;&lt;/p&gt; &lt;p&gt;#define WORD 32&lt;/p&gt; &lt;p&gt;#define SHIFT 5 //移动5个位,左移则相当于乘以32,右移相当于除以32取整&lt;/p&gt; &lt;p&gt;#define MASK 0x1F //六进制下的31&lt;/p&gt; &lt;p&gt;#define N 10000000&lt;/p&gt; &lt;p&gt;//置位函数——用&amp;quot;|&amp;quot;操作符,i&amp;amp;MASK相当于mod操作&lt;/p&gt; &lt;p&gt;//m mod n 运算，当n = 2的X次幂的时候,m mod n = m&amp;amp;(n-1)&lt;/p&gt; &lt;p&gt;void set(int i)&lt;/p&gt; &lt;p&gt;&amp;#123;a[i&amp;gt;&amp;gt;SHIFT]|=(1&amp;lt;&amp;lt;(i&amp;amp;MASK));&amp;#125;&lt;/p&gt; &lt;p&gt;//清除位操作，用&amp;amp;~操作符&lt;/p&gt; &lt;p&gt;void clear(int i)&lt;/p&gt; &lt;p&gt;&amp;#123;a[i&amp;gt;&amp;gt;SHIFT]&amp;amp;=~(1&amp;lt;&amp;lt;(i&amp;amp;MASK));&amp;#125;&lt;/p&gt; &lt;p&gt;//测试位操作用&amp;amp;操作符&lt;/p&gt; &lt;p&gt;int test(int i)&lt;/p&gt; &lt;p&gt;&amp;#123;return a[i&amp;gt;&amp;gt;SHIFT]&amp;amp;(1&amp;lt;&amp;lt;(i&amp;amp;MASK));&amp;#125;&lt;/p&gt; &lt;p&gt;重要的是要从十进制运算的思维转化为二进制运算,位逻辑运算不过是工具而已.&lt;/p&gt; &lt;p&gt;习题三 在你自己的系统上实现位图排序并度量其运行时间&lt;/p&gt; &lt;p&gt;解题报告&amp;#58;&lt;/p&gt; &lt;p&gt;#define WORD 32&lt;/p&gt; &lt;p&gt;#define SHIFT 5 //移动5个位,左移则相当于乘以32,右移相当于除以32取整&lt;/p&gt; &lt;p&gt;#define MASK 0x1F //六进制下的31&lt;/p&gt; &lt;p&gt;#define N 10000000&lt;/p&gt; &lt;p&gt;#include &amp;lt;fstream&amp;gt;&lt;/p&gt; &lt;p&gt;#include &amp;lt;iostream&amp;gt;&lt;/p&gt; &lt;p&gt;using namespace std;&lt;/p&gt; &lt;p&gt;//置位函数——用&amp;quot;|&amp;quot;操作符,i&amp;amp;MASK相当于mod操作&lt;/p&gt; &lt;p&gt;//m mod n 运算，当n = 2的X次幂的时候,m mod n = m&amp;amp;(n-1)&lt;/p&gt; &lt;p&gt;void set(int i)&lt;/p&gt; &lt;p&gt;&amp;#123;a[i&amp;gt;&amp;gt;SHIFT]|=(1&amp;lt;&amp;lt;(i&amp;amp;MASK));&amp;#125;&lt;/p&gt; &lt;p&gt;//清除位操作，用&amp;amp;~操作符&lt;/p&gt; &lt;p&gt;void clear(int i)&lt;/p&gt; &lt;p&gt;&amp;#123;a[i&amp;gt;&amp;gt;SHIFT]&amp;amp;=~(1&amp;lt;&amp;lt;(i&amp;amp;MASK));&amp;#125;&lt;/p&gt; &lt;p&gt;//测试位操作用&amp;amp;操作符&lt;/p&gt; &lt;p&gt;int test(int i)&lt;/p&gt; &lt;p&gt;&amp;#123;return a[i&amp;gt;&amp;gt;SHIFT]&amp;amp;(1&amp;lt;&amp;lt;(i&amp;amp;MASK));&amp;#125;&lt;/p&gt; &lt;p&gt;int main()&amp;#123;&lt;/p&gt; &lt;p&gt;ifstream in;&lt;/p&gt; &lt;p&gt;ofstream outt;&lt;/p&gt; &lt;p&gt;in.open(&amp;quot;c&amp;#58;/project/out.txt&amp;quot;);&lt;/p&gt; &lt;p&gt;outt.open(&amp;quot;c&amp;#58;/project/outt.txt&amp;quot;);&lt;/p&gt; &lt;p&gt;int m;&lt;/p&gt; &lt;p&gt;for(int i=0;i&amp;lt;N;i++) clear(i);&lt;/p&gt; &lt;p&gt;for(int i=0;i&amp;lt;N/10;i++) &amp;#123;in&amp;gt;&amp;gt;m; set(m);&amp;#125;&lt;/p&gt; &lt;p&gt;for(int i=0;i&amp;lt;N;i++) &amp;#123;if(test(i)==1) outt&amp;lt;&amp;lt;i&amp;lt;&amp;lt;endl;&amp;#125;&lt;/p&gt; &lt;p&gt;in.close();&lt;/p&gt; &lt;p&gt;outt.close();&lt;/p&gt; &lt;p&gt;return 0;&lt;/p&gt; &lt;p&gt;&amp;#125;&lt;/p&gt; &lt;p&gt;为什么说这个算法时空效率达到极致呢？我们对１００万个不重复的正整数（１000,0000以内）的文件进行测试：  &lt;table cellpadding=&quot;0&quot; border=&quot;0&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;p&gt;系统排序&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;C++/STL.set&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;C++/sort&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;C++/位图&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;总时间(s)&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;89&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;38&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;12.6&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;10.7&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;计算时间(s)&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;79&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;28&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;2.4&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;0.5&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;内存使用(MB)&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;0.8&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;70&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;4&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;1.25&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt; &lt;p&gt;（本测试数据是在较旧的电脑上测试的，但还是体现性能的差距） &lt;br /&gt;第一行是总时间，第二行的计算时间是总时间减去数据读取耗时１０.２秒。虽然通用C++程序使用内存和ＣＰＵ时间是专用C++程序（C++位图）的５０倍，但是它的使用仅需要一半的代码，并能很容易扩展到其他问题上，这也是专用C++程序最大的缺点吧。&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/414071400/knightsgang/feedsky/s.gif?r=http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!144.entry&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/knightsgang/414071400/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/knightsgang/414071400/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>Books</category><pubDate>Fri, 10 Jul 2009 11:47:05 +0800</pubDate><comments>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!144.entry#comment</comments><guid isPermaLink="false">5536415C9770F9BF!144</guid><fs:srclink>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!144.entry</fs:srclink><fs:srcfeed>http://cid-5536415c9770f9bf.users.api.live.net/Users(6140167007899810239)/Main?$format=rss20</fs:srcfeed><fs:itemid>feedsky/knightsgang/~7720050/414071400/5829218</fs:itemid></item><item><title>测试博客中的公式输入</title><link>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!141.entry</link><slash:comments>0</slash:comments><live:type>blogentry</live:type><live:typelabel>Blog Entry</live:typelabel><wfw:commentRss>http://cid-5536415c9770f9bf.users.api.live.net:80/Users(6140167007899810239)/Blogs('5536415C9770F9BF!119')/Entries('5536415C9770F9BF!141')/Comments?$format=application%2frss%2bxml</wfw:commentRss><dcterms:modified>2009-06-13T05:14:10.8670000Z</dcterms:modified><description>&lt;p&gt;这是一段用于测试博客中的公式输入的文本：&lt;/p&gt; &lt;p&gt;用word2007+mathtype6.5输入的公式：&lt;span lang=&quot;EN-US&quot; style=&quot;font-size&amp;#58;10.5pt;font-family&amp;#58;'Calibri','sans-serif'&quot;&gt;&lt;span style=&quot;top&amp;#58;16pt&quot;&gt;&lt;a href=&quot;https&amp;#58;//z8acwq.bay.livefilestore.com/y1mFR6zo1coMmOMGOJgtrPPD4q2xj_dOVtCZU2EwGE0MDUIfBpKlArcyBHAebcAhlZy-bg9cL5AVcwyB9hnzEgUAHPPs36DA992fOOxsTXEnadTdYBmntFhmdWHOVoEVpr513WdRchxkd1XhmWfzlneZg/clip_image00211.gif&quot; rel=&quot;WLPP&quot;&gt;&lt;img title=&quot;clip_image002&quot; style=&quot;border-top-width&amp;#58;0px;display&amp;#58;inline;border-left-width&amp;#58;0px;border-bottom-width&amp;#58;0px;border-right-width&amp;#58;0px&quot; height=&quot;43&quot; alt=&quot;clip_image002&quot; src=&quot;https&amp;#58;//z8acwq.bay.livefilestore.com/y1mVoN955YVBumA1bFJnDitxIq9dnfex9TqbfOCHZh2oKjG-BaDXqob-ucYIa2_CWM2eij9rPFpb96px3dluUbRy-cvfKGOwadEhivngF1UvIW-2kz7nrckK5h5ljApeT0kUfKYpsxK66EYdn3JLjmd_A/clip_image002_thumb2.gif&quot; width=&quot;240&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;用word2007输入的公式：&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https&amp;#58;//z8acwq.bay.livefilestore.com/y1mLmNuAL7i5tWECIQhRJb-IRvP0hW3992iypsm7JXbfPIWJbAguZ9EIg27bco5pJEpdaYfqcwCQP_iutRIewfuDCJDx0C2TB1ejVdq6xyWbZLl4_7rIG0WdksA2_N4UEGOMjiQ9tVTW_vQCgKLtR4-uw/clip_image002122.gif&quot; rel=&quot;WLPP&quot;&gt;&lt;img title=&quot;clip_image002[12]&quot; style=&quot;border-top-width&amp;#58;0px;display&amp;#58;inline;border-left-width&amp;#58;0px;border-bottom-width&amp;#58;0px;border-right-width&amp;#58;0px&quot; height=&quot;42&quot; alt=&quot;clip_image002[12]&quot; src=&quot;https&amp;#58;//z8acwq.bay.livefilestore.com/y1mW8qGYYTX0AByW7wIy4YIu78NXk6aDpftFiX5eWtZwGbY5sHgIvtTyWVS-9CMNxuRFZRti3Xi_gM3d35u3wBANJWT0yDG8UtaYxlB_CrSIcR8OmKgBZw3NqIW-QVtcjvSppbT-o5yB6bfys_n3JkQvw/clip_image00212_thumb.gif&quot; width=&quot;201&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https&amp;#58;//z8acwq.bay.livefilestore.com/y1mLmNuAL7i5tWECIQhRJb-IRvP0hW3992iypsm7JXbfPIWJbAguZ9EIg27bco5pJEpdaYfqcwCQP_iutRIewfuDCJDx0C2TB1ejVdq6xyWbZLl4_7rIG0WdksA2_N4UEGOMjiQ9tVTW_vQCgKLtR4-uw/clip_image002122.gif&quot;&gt; &lt;/a&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/414071401/knightsgang/feedsky/s.gif?r=http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!141.entry&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/knightsgang/414071401/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/knightsgang/414071401/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><pubDate>Sat, 13 Jun 2009 13:14:10 +0800</pubDate><comments>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!141.entry#comment</comments><guid isPermaLink="false">5536415C9770F9BF!141</guid><fs:srclink>http://knightsgang.spaces.live.com/Blog/cns!5536415C9770F9BF!141.entry</fs:srclink><fs:srcfeed>http://cid-5536415c9770f9bf.users.api.live.net/Users(6140167007899810239)/Main?$format=rss20</fs:srcfeed><fs:itemid>feedsky/knightsgang/~7720050/414071401/5829218</fs:itemid></item></channel></rss>
