﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Ay's Blog@CNSSUESTC-随笔分类-算法 &amp;&amp; C/C++</title><link>http://www.cppblog.com/ay19880703/category/9055.html</link><description /><language>zh-cn</language><lastBuildDate>Thu, 12 Jan 2012 15:53:15 GMT</lastBuildDate><pubDate>Thu, 12 Jan 2012 15:53:15 GMT</pubDate><ttl>60</ttl><item><title>ATL的offsetofclass中,为啥_ATL_PACKING是8的解释</title><link>http://www.cppblog.com/ay19880703/archive/2012/01/12/164053.html</link><dc:creator>__ay</dc:creator><author>__ay</author><pubDate>Thu, 12 Jan 2012 05:52:00 GMT</pubDate><guid>http://www.cppblog.com/ay19880703/archive/2012/01/12/164053.html</guid><wfw:comment>http://www.cppblog.com/ay19880703/comments/164053.html</wfw:comment><comments>http://www.cppblog.com/ay19880703/archive/2012/01/12/164053.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ay19880703/comments/commentRss/164053.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ay19880703/services/trackbacks/164053.html</trackback:ping><description><![CDATA[
		<p>解答出处</p>
		<p>
				<a href="http://stackoverflow.com/questions/5014061/whats-the-use-of-atl-packing-constant-when-computing-distance-from-the-start-o">http://stackoverflow.com/questions/5014061/whats-the-use-of-atl-packing-constant-when-computing-distance-from-the-start-o</a>
		</p>
		<p> </p>
		<p>C++标准规定:</p>
		<p>编译器的类的类型转换对空指针(NULL)特殊处理,即你NULL进行强制类型转化的结果还是NULL,所以….</p>
		<pre>
				<code>static_cast类型转化的时候,_ATL_PACKING的值得是非零就好</code>
		</pre>
		<pre>
				<code>
				</code> </pre>
		<p>
				<strong>C++ Standard 4.10/3 Pointer conversions [conv.ptr]:</strong>
		</p>
		<p>An rvalue of type “pointer to cv D,” where D is a class type, can be converted to an rvalue of type “pointer to cv B,” where B is a base class (clause 10) of D. If B is an inaccessible (clause 11) or ambiguous (10.2) base class of D, a program that necessitates this conversion is ill-formed. The result of the conversion is a pointer to the base class sub-object of the derived class object. <strong><font color="#ff0000">The null pointer value is converted to the null pointer value of the destination type.</font></strong></p>
<img src ="http://www.cppblog.com/ay19880703/aggbug/164053.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ay19880703/" target="_blank">__ay</a> 2012-01-12 13:52 <a href="http://www.cppblog.com/ay19880703/archive/2012/01/12/164053.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>学校的数据结构试验题目二--哈夫曼树编码</title><link>http://www.cppblog.com/ay19880703/archive/2008/12/09/68937.html</link><dc:creator>__ay</dc:creator><author>__ay</author><pubDate>Tue, 09 Dec 2008 06:42:00 GMT</pubDate><guid>http://www.cppblog.com/ay19880703/archive/2008/12/09/68937.html</guid><wfw:comment>http://www.cppblog.com/ay19880703/comments/68937.html</wfw:comment><comments>http://www.cppblog.com/ay19880703/archive/2008/12/09/68937.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ay19880703/comments/commentRss/68937.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ay19880703/services/trackbacks/68937.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 终于写完了~~我觉得那个解码编码部分还能优化~~  如果有更好的方法欢迎赐教~~呵呵题目:解法:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->  1 #include &lt;iostream&gt;  2 #include &lt;windows....&nbsp;&nbsp;<a href='http://www.cppblog.com/ay19880703/archive/2008/12/09/68937.html'>阅读全文</a><img src ="http://www.cppblog.com/ay19880703/aggbug/68937.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ay19880703/" target="_blank">__ay</a> 2008-12-09 14:42 <a href="http://www.cppblog.com/ay19880703/archive/2008/12/09/68937.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>学校的数据结构试验题目一  背包问题</title><link>http://www.cppblog.com/ay19880703/archive/2008/12/09/68936.html</link><dc:creator>__ay</dc:creator><author>__ay</author><pubDate>Tue, 09 Dec 2008 06:36:00 GMT</pubDate><guid>http://www.cppblog.com/ay19880703/archive/2008/12/09/68936.html</guid><wfw:comment>http://www.cppblog.com/ay19880703/comments/68936.html</wfw:comment><comments>http://www.cppblog.com/ay19880703/archive/2008/12/09/68936.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ay19880703/comments/commentRss/68936.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ay19880703/services/trackbacks/68936.html</trackback:ping><description><![CDATA[题目如下,解法可能不是最好的  若有更好解法  请赐教  <br />初学算法~望多多指教啊~~<br /><br /><img src="http://www.cppblog.com/images/cppblog_com/ay19880703/c.bmp" alt="c.bmp" width="877" border="0" height="321" /><br />解法:<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"><br />
  1</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">  2</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">  3</span> <span style="color: rgb(0, 0, 0);">#include </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">iostream</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">  4</span> <span style="color: rgb(0, 0, 0);">#include </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">windows.h</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">  5</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">  6</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">#define</span><span style="color: rgb(0, 0, 0);"> MAXINPUT 15</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">  7</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">  8</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">namespace</span><span style="color: rgb(0, 0, 0);"> std ;<br /></span><span style="color: rgb(0, 128, 128);">  9</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 10</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">struct</span><span style="color: rgb(0, 0, 0);"> stack {<br /></span><span style="color: rgb(0, 128, 128);"> 11</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">data ;<br /></span><span style="color: rgb(0, 128, 128);"> 12</span> <span style="color: rgb(0, 0, 0);">    stack </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">next ;<br /></span><span style="color: rgb(0, 128, 128);"> 13</span> <span style="color: rgb(0, 0, 0);">} ;<br /></span><span style="color: rgb(0, 128, 128);"> 14</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 15</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 16</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 17</span> <span style="color: rgb(0, 0, 0);">stack </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">push(stack </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">top , </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">data )   </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">压栈</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 18</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 19</span> <span style="color: rgb(0, 0, 0);">    stack </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">tem </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> stack ;<br /></span><span style="color: rgb(0, 128, 128);"> 20</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);"> 21</span> <span style="color: rgb(0, 0, 0);">    tem</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">data </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> data ;<br /></span><span style="color: rgb(0, 128, 128);"> 22</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 23</span> <span style="color: rgb(0, 0, 0);">    tem</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">next </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> top ;<br /></span><span style="color: rgb(0, 128, 128);"> 24</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 25</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> tem ;<br /></span><span style="color: rgb(0, 128, 128);"> 26</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);"> 27</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 28</span> <span style="color: rgb(0, 0, 0);">stack </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">pop(stack </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">top , </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">**</span><span style="color: rgb(0, 0, 0);">data)   </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">出栈</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 29</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">{    <br /></span><span style="color: rgb(0, 128, 128);"> 30</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( top </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> NULL)<br /></span><span style="color: rgb(0, 128, 128);"> 31</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> top ;<br /></span><span style="color: rgb(0, 128, 128);"> 32</span> <span style="color: rgb(0, 0, 0);">    stack </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">tem ;<br /></span><span style="color: rgb(0, 128, 128);"> 33</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 34</span> <span style="color: rgb(0, 0, 0);">    tem </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> top ;<br /></span><span style="color: rgb(0, 128, 128);"> 35</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 36</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">(data) </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> tem</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">data ;<br /></span><span style="color: rgb(0, 128, 128);"> 37</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 38</span> <span style="color: rgb(0, 0, 0);">    top </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> top</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">next ;<br /></span><span style="color: rgb(0, 128, 128);"> 39</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 40</span> <span style="color: rgb(0, 0, 0);">    delete tem ;<br /></span><span style="color: rgb(0, 128, 128);"> 41</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 42</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> top ;<br /></span><span style="color: rgb(0, 128, 128);"> 43</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);"> 44</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 45</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> stackprint(stack </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">top)  </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">打印栈内容</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 46</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 47</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)<br /></span><span style="color: rgb(0, 128, 128);"> 48</span> <span style="color: rgb(0, 0, 0);">    {<br /></span><span style="color: rgb(0, 128, 128);"> 49</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);"> 50</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( top </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> NULL )<br /></span><span style="color: rgb(0, 128, 128);"> 51</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">break</span><span style="color: rgb(0, 0, 0);"> ;<br /></span><span style="color: rgb(0, 128, 128);"> 52</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 53</span> <span style="color: rgb(0, 0, 0);">    cout</span><span style="color: rgb(0, 0, 0);">&lt;&lt;*</span><span style="color: rgb(0, 0, 0);">(top</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">data)</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> ;<br /></span><span style="color: rgb(0, 128, 128);"> 54</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);"> 55</span> <span style="color: rgb(0, 0, 0);">    top </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> top</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">next ;<br /></span><span style="color: rgb(0, 128, 128);"> 56</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);"> 57</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);"> 58</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 59</span> <span style="color: rgb(0, 0, 0);">    cout</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">endl ;<br /></span><span style="color: rgb(0, 128, 128);"> 60</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);"> 61</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 62</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 63</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 64</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> sum </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> , input[MAXINPUT] </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> {</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">}  ;<br /></span><span style="color: rgb(0, 128, 128);"> 65</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 66</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> main(</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">)<br /></span><span style="color: rgb(0, 128, 128);"> 67</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 68</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> count </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> , T </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> ;<br /></span><span style="color: rgb(0, 128, 128);"> 69</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 70</span> <span style="color: rgb(0, 0, 0);">    cout</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">请输入T值</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">endl ;<br /></span><span style="color: rgb(0, 128, 128);"> 71</span> <span style="color: rgb(0, 0, 0);">    cin</span><span style="color: rgb(0, 0, 0);">&gt;&gt;</span><span style="color: rgb(0, 0, 0);">T ;<br /></span><span style="color: rgb(0, 128, 128);"> 72</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 73</span> <span style="color: rgb(0, 0, 0);">    cout</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">请输入w数组数目</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">endl ;<br /></span><span style="color: rgb(0, 128, 128);"> 74</span> <span style="color: rgb(0, 0, 0);">    cin</span><span style="color: rgb(0, 0, 0);">&gt;&gt;</span><span style="color: rgb(0, 0, 0);">count ;<br /></span><span style="color: rgb(0, 128, 128);"> 75</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);"> 76</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( count </span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"> MAXINPUT )<br /></span><span style="color: rgb(0, 128, 128);"> 77</span> <span style="color: rgb(0, 0, 0);">    {<br /></span><span style="color: rgb(0, 128, 128);"> 78</span> <span style="color: rgb(0, 0, 0);">        cout</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">输入溢出</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">endl ;<br /></span><span style="color: rgb(0, 128, 128);"> 79</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> ;<br /></span><span style="color: rgb(0, 128, 128);"> 80</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);"> 81</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 82</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">( </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> ; i </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> count ; i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);"> )<br /></span><span style="color: rgb(0, 128, 128);"> 83</span> <span style="color: rgb(0, 0, 0);">    {<br /></span><span style="color: rgb(0, 128, 128);"> 84</span> <span style="color: rgb(0, 0, 0);">        cout</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">请输入w[</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">i</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">]值</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">endl ;<br /></span><span style="color: rgb(0, 128, 128);"> 85</span> <span style="color: rgb(0, 0, 0);">        cin</span><span style="color: rgb(0, 0, 0);">&gt;&gt;</span><span style="color: rgb(0, 0, 0);">input[i] ;<br /></span><span style="color: rgb(0, 128, 128);"> 86</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);"> 87</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 88</span> <span style="color: rgb(0, 0, 0);">    cout</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">endl</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Loading<img src="../../Images/dot.gif" /><img src="../../Images/dot.gif" /></span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);">endl ;<br /></span><span style="color: rgb(0, 128, 128);"> 89</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);"> 90</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 91</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 92</span> <span style="color: rgb(0, 0, 0);">    stack </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">top </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> NULL ;  </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">初始化栈</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 93</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 94</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">  , </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">temdata </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> input , </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">popdata </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> input , </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">enddata </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">input[count]  ;<br /></span><span style="color: rgb(0, 128, 128);"> 95</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 96</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 97</span> <span style="color: rgb(0, 128, 0);">    栈的非递归调用,<br /></span><span style="color: rgb(0, 128, 128);"> 98</span> <span style="color: rgb(0, 128, 0);">    先压栈数据,然后依次遍历剩余的数据,满足条件打印,小于预期值就压栈<br /></span><span style="color: rgb(0, 128, 128);"> 99</span> <span style="color: rgb(0, 128, 0);">    接着遍历剩余数据,遍历这个层次的数据完了就出栈,然后指针+1(指向下一个数据),继续遍历剩余数据<br /></span><span style="color: rgb(0, 128, 128);">100</span> <span style="color: rgb(0, 128, 0);">    </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">101</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);">102</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)<br /></span><span style="color: rgb(0, 128, 128);">103</span> <span style="color: rgb(0, 0, 0);">    {<br /></span><span style="color: rgb(0, 128, 128);">104</span> <span style="color: rgb(0, 0, 0);">        sum </span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">temdata ;<br /></span><span style="color: rgb(0, 128, 128);">105</span> <span style="color: rgb(0, 0, 0);">        <br /></span><span style="color: rgb(0, 128, 128);">106</span> <span style="color: rgb(0, 0, 0);">        top </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> push(top , temdata) ;<br /></span><span style="color: rgb(0, 128, 128);">107</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);">108</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( sum </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> T )<br /></span><span style="color: rgb(0, 128, 128);">109</span> <span style="color: rgb(0, 0, 0);">        {<br /></span><span style="color: rgb(0, 128, 128);">110</span> <span style="color: rgb(0, 0, 0);">            stackprint(top) ;<br /></span><span style="color: rgb(0, 128, 128);">111</span> <span style="color: rgb(0, 0, 0);">            top </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pop(top,</span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">popdata) ;<br /></span><span style="color: rgb(0, 128, 128);">112</span> <span style="color: rgb(0, 0, 0);">            sum </span><span style="color: rgb(0, 0, 0);">-=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">popdata ;<br /></span><span style="color: rgb(0, 128, 128);">113</span> <span style="color: rgb(0, 0, 0);">            top </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pop(top , </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">popdata ) ;<br /></span><span style="color: rgb(0, 128, 128);">114</span> <span style="color: rgb(0, 0, 0);">            sum </span><span style="color: rgb(0, 0, 0);">-=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">popdata ;<br /></span><span style="color: rgb(0, 128, 128);">115</span> <span style="color: rgb(0, 0, 0);">            temdata </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">popdata ;        <br /></span><span style="color: rgb(0, 128, 128);">116</span> <span style="color: rgb(0, 0, 0);">        <br /></span><span style="color: rgb(0, 128, 128);">117</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">118</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (sum </span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"> T )<br /></span><span style="color: rgb(0, 128, 128);">119</span> <span style="color: rgb(0, 0, 0);">        {<br /></span><span style="color: rgb(0, 128, 128);">120</span> <span style="color: rgb(0, 0, 0);">            top </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pop(top,</span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">popdata) ;<br /></span><span style="color: rgb(0, 128, 128);">121</span> <span style="color: rgb(0, 0, 0);">            sum </span><span style="color: rgb(0, 0, 0);">-=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">popdata ;<br /></span><span style="color: rgb(0, 128, 128);">122</span> <span style="color: rgb(0, 0, 0);">            temdata </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">popdata ;<br /></span><span style="color: rgb(0, 128, 128);">123</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">124</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( sum</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T )<br /></span><span style="color: rgb(0, 128, 128);">125</span> <span style="color: rgb(0, 0, 0);">        {<br /></span><span style="color: rgb(0, 128, 128);">126</span> <span style="color: rgb(0, 0, 0);">            temdata </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">popdata ;<br /></span><span style="color: rgb(0, 128, 128);">127</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">128</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">129</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( (temdata</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> enddata )<br /></span><span style="color: rgb(0, 128, 128);">130</span> <span style="color: rgb(0, 0, 0);">        {<br /></span><span style="color: rgb(0, 128, 128);">131</span> <span style="color: rgb(0, 0, 0);">            top </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pop(top,</span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">popdata) ;<br /></span><span style="color: rgb(0, 128, 128);">132</span> <span style="color: rgb(0, 0, 0);">            sum </span><span style="color: rgb(0, 0, 0);">-=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">popdata ;            <br /></span><span style="color: rgb(0, 128, 128);">133</span> <span style="color: rgb(0, 0, 0);">            top </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pop(top,</span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">popdata) ;<br /></span><span style="color: rgb(0, 128, 128);">134</span> <span style="color: rgb(0, 0, 0);">            sum </span><span style="color: rgb(0, 0, 0);">-=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">popdata ;<br /></span><span style="color: rgb(0, 128, 128);">135</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">136</span> <span style="color: rgb(0, 0, 0);">            temdata </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">popdata ;<br /></span><span style="color: rgb(0, 128, 128);">137</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">138</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);">139</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( top </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> NULL </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);">  popdata </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> enddata)<br /></span><span style="color: rgb(0, 128, 128);">140</span> <span style="color: rgb(0, 0, 0);">                </span><span style="color: rgb(0, 0, 255);">break</span><span style="color: rgb(0, 0, 0);"> ;<br /></span><span style="color: rgb(0, 128, 128);">141</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);">142</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">143</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">144</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">145</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">146</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);">147</span> <span style="color: rgb(0, 0, 0);">    system(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">pause</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) ;<br /></span><span style="color: rgb(0, 128, 128);">148</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">149</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">150</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">151</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">152</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">153</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">154</span> <span style="color: rgb(0, 0, 0);"></span></div><br /><br /><img src ="http://www.cppblog.com/ay19880703/aggbug/68936.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ay19880703/" target="_blank">__ay</a> 2008-12-09 14:36 <a href="http://www.cppblog.com/ay19880703/archive/2008/12/09/68936.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>