﻿<?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++博客-codepeng</title><link>http://www.cppblog.com/codepeng/</link><description /><language>zh-cn</language><lastBuildDate>Wed, 08 Apr 2026 16:38:46 GMT</lastBuildDate><pubDate>Wed, 08 Apr 2026 16:38:46 GMT</pubDate><ttl>60</ttl><item><title>fzu OJ Problem 2064 找位置</title><link>http://www.cppblog.com/codepeng/archive/2011/12/13/162057.html</link><dc:creator>acpeng</dc:creator><author>acpeng</author><pubDate>Tue, 13 Dec 2011 14:06:00 GMT</pubDate><guid>http://www.cppblog.com/codepeng/archive/2011/12/13/162057.html</guid><wfw:comment>http://www.cppblog.com/codepeng/comments/162057.html</wfw:comment><comments>http://www.cppblog.com/codepeng/archive/2011/12/13/162057.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/codepeng/comments/commentRss/162057.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/codepeng/services/trackbacks/162057.html</trackback:ping><description><![CDATA[又刷一道水题，地址：<a href="http://acm.fzu.edu.cn/problem.php?pid=2064">http://acm.fzu.edu.cn/problem.php?pid=2064</a><br /><br />内容不复述，直接code
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><img id="Code_Closed_Image_220528" onclick="this.style.display='none'; Code_Closed_Text_220528.style.display='none'; Code_Open_Image_220528.style.display='inline'; Code_Open_Text_220528.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" width="11" height="16"><img style="display: none" id="Code_Open_Image_220528" onclick="this.style.display='none'; Code_Open_Text_220528.style.display='none'; Code_Closed_Image_220528.style.display='inline'; Code_Closed_Text_220528.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16"><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Code_Closed_Text_220528"></span><span style="display: none" id="Code_Open_Text_220528"><br /><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000">#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">stdio.h</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;data[</span><span style="color: #000000">103</span><span style="color: #000000">][</span><span style="color: #000000">103</span><span style="color: #000000">];<br /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;flg_1,flg_2;<br /></span><span style="color: #008000">//</span><span style="color: #008000">搜索data[i][j]&nbsp;~&nbsp;data[i][j+w-1],若符合，返回1;否则返回0，flg_1为最后一个1的位置</span><span style="color: #008000"><br /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;search(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;a[],</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;j,</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;w)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">j</span><span style="color: #000000">+</span><span style="color: #000000">w</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">;i</span><span style="color: #000000">&gt;=</span><span style="color: #000000">j;i</span><span style="color: #000000">--</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(a[i]</span><span style="color: #000000">!=</span><span style="color: #000000">0</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flg_1</span><span style="color: #000000">=</span><span style="color: #000000">i;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br />}<br /></span><span style="color: #008000">//</span><span style="color: #008000">找出data数据第&nbsp;i&nbsp;行data[i][j]之后的第一个1的位置，返回之间的0的个数</span><span style="color: #008000"><br /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;find1behind(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;a[],</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;j,</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;m)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i,cont</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;j</span><span style="color: #000000">+</span><span style="color: #000000">i</span><span style="color: #000000">&lt;=</span><span style="color: #000000">m;j</span><span style="color: #000000">++</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(a[j</span><span style="color: #000000">+</span><span style="color: #000000">i]</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)cont</span><span style="color: #000000">++</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">break</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;flg_2</span><span style="color: #000000">=</span><span style="color: #000000">j</span><span style="color: #000000">+</span><span style="color: #000000">i;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;cont;<br />}<br /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;T,N,M,W,i,j,tmp,cont;<br />&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">T);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(T</span><span style="color: #000000">--</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d%d%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">N,</span><span style="color: #000000">&amp;</span><span style="color: #000000">M,</span><span style="color: #000000">&amp;</span><span style="color: #000000">W);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;i</span><span style="color: #000000">&lt;</span><span style="color: #000000">N;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(j</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;j</span><span style="color: #000000">&lt;</span><span style="color: #000000">M;j</span><span style="color: #000000">++</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">data[i][j]);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cont</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;i</span><span style="color: #000000">&lt;</span><span style="color: #000000">N;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(j</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;j</span><span style="color: #000000">&lt;=</span><span style="color: #000000">M</span><span style="color: #000000">-</span><span style="color: #000000">W;j</span><span style="color: #000000">++</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tmp</span><span style="color: #000000">=</span><span style="color: #000000">search(data[i],j,W);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(tmp</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j</span><span style="color: #000000">=</span><span style="color: #000000">flg_1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cont</span><span style="color: #000000">++</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cont</span><span style="color: #000000">+=</span><span style="color: #000000">find1behind(data[i],j</span><span style="color: #000000">+</span><span style="color: #000000">W,M</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j</span><span style="color: #000000">=</span><span style="color: #000000">flg_2;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%d\n</span><span style="color: #000000">"</span><span style="color: #000000">,cont);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br />}</span></span></div><br /><br /><img src ="http://www.cppblog.com/codepeng/aggbug/162057.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/codepeng/" target="_blank">acpeng</a> 2011-12-13 22:06 <a href="http://www.cppblog.com/codepeng/archive/2011/12/13/162057.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU  2084  数塔</title><link>http://www.cppblog.com/codepeng/archive/2011/10/03/157404.html</link><dc:creator>acpeng</dc:creator><author>acpeng</author><pubDate>Mon, 03 Oct 2011 04:16:00 GMT</pubDate><guid>http://www.cppblog.com/codepeng/archive/2011/10/03/157404.html</guid><wfw:comment>http://www.cppblog.com/codepeng/comments/157404.html</wfw:comment><comments>http://www.cppblog.com/codepeng/archive/2011/10/03/157404.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/codepeng/comments/commentRss/157404.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/codepeng/services/trackbacks/157404.html</trackback:ping><description><![CDATA[题目链接：<a href="http://acm.hdu.edu.cn/showproblem.php?pid=2084">http://acm.hdu.edu.cn/showproblem.php?pid=2084</a><br /><img src="http://acm.hdu.edu.cn/data/images/2084-1.jpg"  alt="" /><br /><br /><span style="color: red">经典入门级DP，自底向上，层层递进。（所谓的记忆化搜索）
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000">#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">stdio.h</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /></span><span style="color: #0000ff">#define</span><span style="color: #000000">&nbsp;max(a,b)&nbsp;(a)&gt;(b)?(a):(b)</span><span style="color: #000000"><br /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;a[</span><span style="color: #000000">103</span><span style="color: #000000">][</span><span style="color: #000000">103</span><span style="color: #000000">];<br /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;t,n,i,j;<br />&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">t);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(t</span><span style="color: #000000">--</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">n);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;i</span><span style="color: #000000">&lt;</span><span style="color: #000000">n;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(j</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;j</span><span style="color: #000000">&lt;=</span><span style="color: #000000">i;j</span><span style="color: #000000">++</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">a[i][j]);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">n</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">;i</span><span style="color: #000000">&gt;</span><span style="color: #000000">0</span><span style="color: #000000">;i</span><span style="color: #000000">--</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(j</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;j</span><span style="color: #000000">&lt;</span><span style="color: #000000">i;j</span><span style="color: #000000">++</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a[i</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">][j]</span><span style="color: #000000">+=</span><span style="color: #000000">max(a[i][j],a[i][j</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%d\n</span><span style="color: #000000">"</span><span style="color: #000000">,a[</span><span style="color: #000000">0</span><span style="color: #000000">][</span><span style="color: #000000">0</span><span style="color: #000000">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br />}</span></div><br /></span> <img src ="http://www.cppblog.com/codepeng/aggbug/157404.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/codepeng/" target="_blank">acpeng</a> 2011-10-03 12:16 <a href="http://www.cppblog.com/codepeng/archive/2011/10/03/157404.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 1160  ZOJ 1108  FatMouse's Speed</title><link>http://www.cppblog.com/codepeng/archive/2011/10/03/157386.html</link><dc:creator>acpeng</dc:creator><author>acpeng</author><pubDate>Sun, 02 Oct 2011 19:24:00 GMT</pubDate><guid>http://www.cppblog.com/codepeng/archive/2011/10/03/157386.html</guid><wfw:comment>http://www.cppblog.com/codepeng/comments/157386.html</wfw:comment><comments>http://www.cppblog.com/codepeng/archive/2011/10/03/157386.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/codepeng/comments/commentRss/157386.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/codepeng/services/trackbacks/157386.html</trackback:ping><description><![CDATA[<div>题目链接：<a href="http://acm.hdu.edu.cn/showproblem.php?pid=1160">http://acm.hdu.edu.cn/showproblem.php?pid=1160</a><br />
<div class="panel_title" align="left"><strong style="color: red">Problem Description</strong></div>
<div class="panel_content">FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence so that the weights are increasing, but the speeds are decreasing.<br /></div>
<div class="panel_bottom">&nbsp;</div>
<div class="panel_title" align="left"><strong style="color: red">Input</strong></div>
<div class="panel_content">Input contains data for a bunch of mice, one mouse per line, terminated by end of file.<br />The data for a particular mouse will consist of a pair of integers: the first representing its size in grams and the second representing its speed in centimeters per second. Both integers are between 1 and 10000. The data in each test case will contain information for at most 1000 mice.<br />Two mice may have the same weight, the same speed, or even the same weight and speed. <br /></div>
<div class="panel_title" align="left"><strong style="color: red">Output</strong></div>
<div class="panel_content">Your program should output a sequence of lines of data; the first line should contain a number n; the remaining n lines should each contain a single positive integer (each one representing a mouse). If these n integers are m[1], m[2],..., m[n] then it must be the case that <br /><br /><span style="color: #0000ff"><strong>W[m[1]] &lt; W[m[2]] &lt; ... &lt; W[m[n]]</strong></span><br /><br />and <br /><br /><span style="color: #0000ff"><strong>S[m[1]] &gt; S[m[2]] &gt; ... &gt; S[m[n]]</strong></span><br /><br />In order for the answer to be correct, n should be as large as possible.<br />All inequalities are strict: weights must be strictly increasing, and speeds must be strictly decreasing. There may be many correct outputs for a given input, your program only needs to find one. <br /></div>
<div class="panel_bottom">&nbsp;<br /><strong style="color: #ff0000">Sample Input</strong></div>
<div class="panel_content"><pre><div style="font-family: Courier New,Courier,monospace">6008 1300
6000 2100
500 2000
1000 4000
1100 3000
6000 2000
8000 1400
6000 1200
2000 1900<br /><br /><br /><br /><br /></div></pre></div>
<div class="panel_title" align="left"><strong style="color: #ff0000">Sample Output</strong></div>
<div class="panel_content"><pre><div style="font-family: Courier New,Courier,monospace">4
4
5<span>
9
7</span><br /><span>解题思</span><span>路：</span><br /><span style="color: #008000">首先根据weight的数值由小到大排序，然后再以speed为标准，求最长下降子序列，思路还是DP，但是要标记子序列的下标</span><br /><span style="color: #008000">麻烦多了，我的做</span><span style="color: #008000">法：</span><br /><span style="color: #008000">定义MaxInclud</span><span style="color: #008000">eEnd数组，令MaxIncludeEnd[i]表示以a[i]结尾的最长下降子序列的长度，那么</span><br /><span style="color: #008000">MaxIncludeEnd[i]=max{ MaxIncludeEnd[i] , a[j]&gt;a[i] ? (MaxIncludeEnd[j]+1) ：-1; }</span><br /><span style="color: #008000">其中j=0:i-1;MaxIncludeEnd[i]的初始值为1,每一个i结束后用max和MaxIncludeEnd[i]比较，更新max和下标max_flg。</span><br /><span style="color: #008000">因为要标记下标，在计算MaxIncludeEnd[i]后，用flg[i]表示以a[i]结尾的最长下降子序列的前一个元素的下标，这样计算完</span><br /><span style="color: #008000">MaxIncludeEnd[n]并更新完max和max_flg以后，循环递推一次就可以得到所有的元素下标，即flg[max_flg],flg[ flg[max_flg] ],&#8230;&#8230;</span><br /><span style="color: #008000">当然这里的下标是逆向的，要设置个新的数组来将其逆转。</span><br /><span style="color: #008000">ps：如果从后往前计算最长上升子序列</span><span style="color: #008000">，那就不</span><span style="color: #008000">必如此麻烦，</span><span style="color: #008000">减少空间。<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><img id="Code_Closed_Image_032916" onclick="this.style.display='none'; Code_Closed_Text_032916.style.display='none'; Code_Open_Image_032916.style.display='inline'; Code_Open_Text_032916.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" width="11" height="16"><img style="display: none" id="Code_Open_Image_032916" onclick="this.style.display='none'; Code_Open_Text_032916.style.display='none'; Code_Closed_Image_032916.style.display='inline'; Code_Closed_Text_032916.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16"><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Code_Closed_Text_032916">code</span><span style="display: none" id="Code_Open_Text_032916"><br /><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000">#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">cstdio</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br />#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">algorithm</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;std;<br /></span><span style="color: #0000ff">struct</span><span style="color: #000000">&nbsp;mouse<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;weight;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;speed;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;num;<br />}mice[</span><span style="color: #000000">1002</span><span style="color: #000000">];<br /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;MaxIncludeEnd[</span><span style="color: #000000">1002</span><span style="color: #000000">],flg[</span><span style="color: #000000">1002</span><span style="color: #000000">],rst[</span><span style="color: #000000">1002</span><span style="color: #000000">];<br /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;cmp(</span><span style="color: #0000ff">struct</span><span style="color: #000000">&nbsp;mouse&nbsp;a,</span><span style="color: #0000ff">struct</span><span style="color: #000000">&nbsp;mouse&nbsp;b)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(a.weight</span><span style="color: #000000">&lt;</span><span style="color: #000000">b.weight)</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br />}<br /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;w,s,i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">,j,k,size,max,max_flg;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">w,</span><span style="color: #000000">&amp;</span><span style="color: #000000">s)</span><span style="color: #000000">!=</span><span style="color: #000000">EOF)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mice[i].weight</span><span style="color: #000000">=</span><span style="color: #000000">w;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mice[i].speed</span><span style="color: #000000">=</span><span style="color: #000000">s;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mice[i].num</span><span style="color: #000000">=</span><span style="color: #000000">i</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;size</span><span style="color: #000000">=</span><span style="color: #000000">i;<br />&nbsp;&nbsp;&nbsp;&nbsp;sort(mice,mice</span><span style="color: #000000">+</span><span style="color: #000000">size,cmp);<br />&nbsp;&nbsp;&nbsp;&nbsp;max</span><span style="color: #000000">=</span><span style="color: #000000">max_flg</span><span style="color: #000000">=</span><span style="color: #000000">flg[</span><span style="color: #000000">0</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;i</span><span style="color: #000000">&lt;</span><span style="color: #000000">size;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MaxIncludeEnd[i]</span><span style="color: #000000">=</span><span style="color: #000000">1</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(j</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;j</span><span style="color: #000000">&lt;</span><span style="color: #000000">i;j</span><span style="color: #000000">++</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(mice[i].speed</span><span style="color: #000000">&lt;</span><span style="color: #000000">mice[j].speed&nbsp;</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">&nbsp;mice[i].weight</span><span style="color: #000000">&gt;</span><span style="color: #000000">mice[j].weight&nbsp;</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">&nbsp;MaxIncludeEnd[j]</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">&gt;</span><span style="color: #000000">MaxIncludeEnd[i])<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MaxIncludeEnd[i]</span><span style="color: #000000">=</span><span style="color: #000000">MaxIncludeEnd[j]</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flg[i]</span><span style="color: #000000">=</span><span style="color: #000000">j;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(max</span><span style="color: #000000">&lt;</span><span style="color: #000000">MaxIncludeEnd[i])<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;max</span><span style="color: #000000">=</span><span style="color: #000000">MaxIncludeEnd[i];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;max_flg</span><span style="color: #000000">=</span><span style="color: #000000">i;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%d\n</span><span style="color: #000000">"</span><span style="color: #000000">,max);<br />&nbsp;&nbsp;&nbsp;&nbsp;k</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(max</span><span style="color: #000000">--</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rst[k</span><span style="color: #000000">++</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #000000">max_flg;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;max_flg</span><span style="color: #000000">=</span><span style="color: #000000">flg[max_flg];<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(k</span><span style="color: #000000">--</span><span style="color: #000000">;k</span><span style="color: #000000">&gt;=</span><span style="color: #000000">0</span><span style="color: #000000">;k</span><span style="color: #000000">--</span><span style="color: #000000">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%d\n</span><span style="color: #000000">"</span><span style="color: #000000">,mice[rst[k]].num);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br />}</span></span></div><br /></span><br /><br /></div></pre></div></div> <img src ="http://www.cppblog.com/codepeng/aggbug/157386.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/codepeng/" target="_blank">acpeng</a> 2011-10-03 03:24 <a href="http://www.cppblog.com/codepeng/archive/2011/10/03/157386.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 1087  Super Jumping</title><link>http://www.cppblog.com/codepeng/archive/2011/10/03/157380.html</link><dc:creator>acpeng</dc:creator><author>acpeng</author><pubDate>Sun, 02 Oct 2011 17:28:00 GMT</pubDate><guid>http://www.cppblog.com/codepeng/archive/2011/10/03/157380.html</guid><wfw:comment>http://www.cppblog.com/codepeng/comments/157380.html</wfw:comment><comments>http://www.cppblog.com/codepeng/archive/2011/10/03/157380.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/codepeng/comments/commentRss/157380.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/codepeng/services/trackbacks/157380.html</trackback:ping><description><![CDATA[<div>题目链接：<a href="http://acm.hdu.edu.cn/showproblem.php?pid=1087">http://acm.hdu.edu.cn/showproblem.php?pid=1087</a><br />
<div class="panel_title" align="left"><strong style="color: #3366ff">Problem Description</strong></div>
<div class="panel_content">Nowadays, a kind of chess game called &#8220;Super Jumping! Jumping! Jumping!&#8221; is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.<br /><br />
<center><img src="http://acm.hdu.edu.cn/data/images/1087-1.jpg"  alt="" /></center><br />The game can be played by two or more than two players. It consists of a chessboard（棋盘）and some chessmen（棋子）, and all chessmen are marked by a positive integer or &#8220;start&#8221; or &#8220;end&#8221;. The player starts from start-point and must jumps into end-point finally. In the course of jumping, the player will visit the chessmen in the path, but everyone must jumps from one chessman to another absolutely bigger (you can assume start-point is a minimum and end-point is a maximum.). And all players cannot go backwards. One jumping can go from a chessman to next, also can go across many chessmen, and even you can straightly get to end-point from start-point. Of course you get zero point in this situation. A player is a winner if and only if he can get a bigger score according to his jumping solution. Note that your score comes from the sum of value on the chessmen in you jumping path.<br />Your task is to output the maximum value according to the given chessmen list.<br /></div>
<div class="panel_title" align="left"><span style="color: #3366ff"><strong>Input</strong></span></div>
<div class="panel_content">Input contains multiple test cases. Each test case is described in a line as follow:<br />N value_1 value_2 &#8230;value_N <br />It is guarantied that N is not more than 1000 and all value_i are in the range of 32-int.<br />A test case starting with 0 terminates the input and this test case is not to be processed.<br /></div>
<div class="panel_title" align="left"><strong style="color: #3366ff">Output</strong></div>
<div class="panel_content">For each case, print the maximum according to rules, and one line one case.<br /><br /><span style="color: #ff0000"><strong>Sample Input</strong></span></div>
<div class="panel_content"><pre><div style="font-family: Courier New,Courier,monospace">3 1 3 2
4 1 2 3 4
4 3 3 2 1
0<br /></div></pre></div>
<div class="panel_title" align="left"><strong style="color: #ff0000">Sample Output</strong></div>
<div class="panel_content"><pre><div style="font-family: Courier New,Courier,monospace">4
10
3<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />典型的入门级DP题，解题思路：<br />定义MaxIncludeEnd数组，令MaxIncludeEnd[i]表示以a[i]结尾的最大和，那么<br />MaxIncludeEnd[i]=max{ MaxIncludeEnd[i] , a[j]&lt;a[i] ? (MaxIncludeEnd[j]+a[i]) ：-1; }<br />其中j=0 to i-1;MaxIncludeEnd[i]的初始值为a[i]。<br /><div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #000000">#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">stdio.h</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;a[</span><span style="color: #000000">1003</span><span style="color: #000000">],MaxIncludeEnd[</span><span style="color: #000000">1003</span><span style="color: #000000">];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_62_455_Open_Image" onclick="this.style.display='none'; Codehighlighter1_62_455_Open_Text.style.display='none'; Codehighlighter1_62_455_Closed_Image.style.display='inline'; Codehighlighter1_62_455_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_62_455_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_62_455_Closed_Text.style.display='none'; Codehighlighter1_62_455_Open_Image.style.display='inline'; Codehighlighter1_62_455_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_62_455_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_62_455_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;n,max,i,j;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">n),n)<br /><img id="Codehighlighter1_106_442_Open_Image" onclick="this.style.display='none'; Codehighlighter1_106_442_Open_Text.style.display='none'; Codehighlighter1_106_442_Closed_Image.style.display='inline'; Codehighlighter1_106_442_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_106_442_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_106_442_Closed_Text.style.display='none'; Codehighlighter1_106_442_Open_Image.style.display='inline'; Codehighlighter1_106_442_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_106_442_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_106_442_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;i</span><span style="color: #000000">&lt;</span><span style="color: #000000">n;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img id="Codehighlighter1_129_181_Open_Image" onclick="this.style.display='none'; Codehighlighter1_129_181_Open_Text.style.display='none'; Codehighlighter1_129_181_Closed_Image.style.display='inline'; Codehighlighter1_129_181_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_129_181_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_129_181_Closed_Text.style.display='none'; Codehighlighter1_129_181_Open_Image.style.display='inline'; Codehighlighter1_129_181_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_129_181_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_129_181_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">a[i]);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MaxIncludeEnd[i]</span><span style="color: #000000">=</span><span style="color: #000000">a[i];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;max</span><span style="color: #000000">=</span><span style="color: #000000">MaxIncludeEnd[</span><span style="color: #000000">0</span><span style="color: #000000">];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;i</span><span style="color: #000000">&lt;</span><span style="color: #000000">n;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img id="Codehighlighter1_228_416_Open_Image" onclick="this.style.display='none'; Codehighlighter1_228_416_Open_Text.style.display='none'; Codehighlighter1_228_416_Closed_Image.style.display='inline'; Codehighlighter1_228_416_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_228_416_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_228_416_Closed_Text.style.display='none'; Codehighlighter1_228_416_Open_Image.style.display='inline'; Codehighlighter1_228_416_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_228_416_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_228_416_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(j</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;j</span><span style="color: #000000">&lt;</span><span style="color: #000000">i;j</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img id="Codehighlighter1_253_363_Open_Image" onclick="this.style.display='none'; Codehighlighter1_253_363_Open_Text.style.display='none'; Codehighlighter1_253_363_Closed_Image.style.display='inline'; Codehighlighter1_253_363_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_253_363_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_253_363_Closed_Text.style.display='none'; Codehighlighter1_253_363_Open_Image.style.display='inline'; Codehighlighter1_253_363_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_253_363_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_253_363_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(a[j]</span><span style="color: #000000">&lt;</span><span style="color: #000000">a[i]&nbsp;</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">&nbsp;MaxIncludeEnd[j]</span><span style="color: #000000">+</span><span style="color: #000000">a[i]</span><span style="color: #000000">&gt;</span><span style="color: #000000">MaxIncludeEnd[i])<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MaxIncludeEnd[i]</span><span style="color: #000000">=</span><span style="color: #000000">MaxIncludeEnd[j]</span><span style="color: #000000">+</span><span style="color: #000000">a[i];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(max</span><span style="color: #000000">&lt;</span><span style="color: #000000">MaxIncludeEnd[i])max</span><span style="color: #000000">=</span><span style="color: #000000">MaxIncludeEnd[i];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%d\n</span><span style="color: #000000">"</span><span style="color: #000000">,max);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span></div><br /><br /><br /></div></pre></div></div><img src ="http://www.cppblog.com/codepeng/aggbug/157380.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/codepeng/" target="_blank">acpeng</a> 2011-10-03 01:28 <a href="http://www.cppblog.com/codepeng/archive/2011/10/03/157380.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ZOJ1292 , HDU  1047 Integer Inquiry</title><link>http://www.cppblog.com/codepeng/archive/2011/09/05/155171.html</link><dc:creator>acpeng</dc:creator><author>acpeng</author><pubDate>Mon, 05 Sep 2011 15:22:00 GMT</pubDate><guid>http://www.cppblog.com/codepeng/archive/2011/09/05/155171.html</guid><wfw:comment>http://www.cppblog.com/codepeng/comments/155171.html</wfw:comment><comments>http://www.cppblog.com/codepeng/archive/2011/09/05/155171.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/codepeng/comments/commentRss/155171.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/codepeng/services/trackbacks/155171.html</trackback:ping><description><![CDATA[<div>大数相加，字符模拟<br />题目链接：<br />ZOJ：<a href="http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1292">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1292</a><br />HDU：<a href="http://acm.hdu.edu.cn/showproblem.php?pid=1047">http://acm.hdu.edu.cn/showproblem.php?pid=1047</a><br /><br /><strong>Description<br /></strong>One of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers. 
<p>``This supercomputer is great,'' remarked Chip. ``I only wish Timothy were here to see these results.'' (Chip moved to a new apartment, once one became available on the third floor of the Lemon Sky apartments on Third Street.) </p>
<p><br /><strong>Input</strong><br />The input will consist of at most 100 lines of text, each of which contains a single VeryLongInteger. Each VeryLongInteger will be 100 or fewer characters in length, and will only contain digits (no VeryLongInteger will be negative). </p>
<p>The final input line will contain a single zero on a line by itself. </p>
<p><br /><strong>Output</strong><br />Your program should output the sum of the VeryLongIntegers given in the input. </p>
<p><br /><strong>This problem contains multiple test cases!</strong></p>
<p>The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.</p>
<p>The output format consists of N output blocks. There is a blank line between output blocks.</p>
<p><strong><br />Sample Input</strong></p>1<br /><br />
<p>123456789012345678901234567890<br />123456789012345678901234567890<br />123456789012345678901234567890<br />0</p>
<p><strong><br />Sample Output</strong></p>
<p>370370367037037036703703703670<br /><br />AC代码：</p>
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img id="Codehighlighter1_0_39_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_39_Open_Text.style.display='none'; Codehighlighter1_0_39_Closed_Image.style.display='inline'; Codehighlighter1_0_39_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_0_39_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_0_39_Closed_Text.style.display='none'; Codehighlighter1_0_39_Open_Image.style.display='inline'; Codehighlighter1_0_39_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_0_39_Closed_Text">/**/</span><span id="Codehighlighter1_0_39_Open_Text"><span style="color: #008000">/*</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />Accepted&nbsp;1047&nbsp;0MS&nbsp;188K&nbsp;1256&nbsp;B&nbsp;C++&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" /></span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">stdio.h</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#include</span><span style="color: #000000">&lt;</span><span style="color: #0000ff">string</span><span style="color: #000000">.h</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">#define</span><span style="color: #000000">&nbsp;MaxSize&nbsp;1000</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;FunBigAdd(</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">str1,</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">str2);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_149_558_Open_Image" onclick="this.style.display='none'; Codehighlighter1_149_558_Open_Text.style.display='none'; Codehighlighter1_149_558_Closed_Image.style.display='inline'; Codehighlighter1_149_558_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_149_558_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_149_558_Closed_Text.style.display='none'; Codehighlighter1_149_558_Open_Image.style.display='inline'; Codehighlighter1_149_558_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_149_558_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_149_558_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;IntStr[MaxSize]</span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">\0</span><span style="color: #000000">"</span><span style="color: #000000">,str[MaxSize]</span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">\0</span><span style="color: #000000">"</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;T,i;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">T);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(T</span><span style="color: #000000">--</span><span style="color: #000000">)<br /><img id="Codehighlighter1_239_545_Open_Image" onclick="this.style.display='none'; Codehighlighter1_239_545_Open_Text.style.display='none'; Codehighlighter1_239_545_Closed_Image.style.display='inline'; Codehighlighter1_239_545_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_239_545_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_239_545_Closed_Text.style.display='none'; Codehighlighter1_239_545_Open_Image.style.display='inline'; Codehighlighter1_239_545_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_239_545_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_239_545_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset(str,</span><span style="color: #000000">0</span><span style="color: #000000">,MaxSize);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%s</span><span style="color: #000000">"</span><span style="color: #000000">,IntStr);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(strcmp(IntStr,</span><span style="color: #000000">"</span><span style="color: #000000">0</span><span style="color: #000000">"</span><span style="color: #000000">)</span><span style="color: #000000">!=</span><span style="color: #000000">0</span><span style="color: #000000">)<br /><img id="Codehighlighter1_321_403_Open_Image" onclick="this.style.display='none'; Codehighlighter1_321_403_Open_Text.style.display='none'; Codehighlighter1_321_403_Closed_Image.style.display='inline'; Codehighlighter1_321_403_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_321_403_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_321_403_Closed_Text.style.display='none'; Codehighlighter1_321_403_Open_Image.style.display='inline'; Codehighlighter1_321_403_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_321_403_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_321_403_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FunBigAdd(str,IntStr);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset(IntStr,</span><span style="color: #000000">0</span><span style="color: #000000">,MaxSize);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%s</span><span style="color: #000000">"</span><span style="color: #000000">,IntStr);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(str[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">0</span><span style="color: #000000">'</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">&nbsp;str[i]</span><span style="color: #000000">!=</span><span style="color: #000000">'</span><span style="color: #000000">\0</span><span style="color: #000000">'</span><span style="color: #000000">)i</span><span style="color: #000000">++</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(str[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">\0</span><span style="color: #000000">'</span><span style="color: #000000">)printf(</span><span style="color: #000000">"</span><span style="color: #000000">0\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%s\n</span><span style="color: #000000">"</span><span style="color: #000000">,str</span><span style="color: #000000">+</span><span style="color: #000000">i);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(T</span><span style="color: #000000">!=</span><span style="color: #000000">0</span><span style="color: #000000">)printf(</span><span style="color: #000000">"</span><span style="color: #000000">\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;strRevg(</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">str)<br /><img id="Codehighlighter1_584_728_Open_Image" onclick="this.style.display='none'; Codehighlighter1_584_728_Open_Text.style.display='none'; Codehighlighter1_584_728_Closed_Image.style.display='inline'; Codehighlighter1_584_728_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_584_728_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_584_728_Closed_Text.style.display='none'; Codehighlighter1_584_728_Open_Image.style.display='inline'; Codehighlighter1_584_728_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_584_728_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_584_728_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;temp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;lgth</span><span style="color: #000000">=</span><span style="color: #000000">(</span><span style="color: #0000ff">int</span><span style="color: #000000">)strlen(str)</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;i</span><span style="color: #000000">&lt;</span><span style="color: #000000">lgth</span><span style="color: #000000">-</span><span style="color: #000000">i;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img id="Codehighlighter1_658_726_Open_Image" onclick="this.style.display='none'; Codehighlighter1_658_726_Open_Text.style.display='none'; Codehighlighter1_658_726_Closed_Image.style.display='inline'; Codehighlighter1_658_726_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_658_726_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_658_726_Closed_Text.style.display='none'; Codehighlighter1_658_726_Open_Image.style.display='inline'; Codehighlighter1_658_726_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_658_726_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_658_726_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;temp</span><span style="color: #000000">=*</span><span style="color: #000000">(str</span><span style="color: #000000">+</span><span style="color: #000000">i);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">(str</span><span style="color: #000000">+</span><span style="color: #000000">i)</span><span style="color: #000000">=*</span><span style="color: #000000">(str</span><span style="color: #000000">+</span><span style="color: #000000">lgth</span><span style="color: #000000">-</span><span style="color: #000000">i);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">(str</span><span style="color: #000000">+</span><span style="color: #000000">lgth</span><span style="color: #000000">-</span><span style="color: #000000">i)</span><span style="color: #000000">=</span><span style="color: #000000">temp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;FunBigAdd(</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">str1,</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">str2)<br /><img id="Codehighlighter1_768_1171_Open_Image" onclick="this.style.display='none'; Codehighlighter1_768_1171_Open_Text.style.display='none'; Codehighlighter1_768_1171_Closed_Image.style.display='inline'; Codehighlighter1_768_1171_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_768_1171_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_768_1171_Closed_Text.style.display='none'; Codehighlighter1_768_1171_Open_Image.style.display='inline'; Codehighlighter1_768_1171_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_768_1171_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_768_1171_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">,dec</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">,tmp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;strRevg(str1);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;strRevg(str2);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(</span><span style="color: #000000">*</span><span style="color: #000000">(str1</span><span style="color: #000000">+</span><span style="color: #000000">i)</span><span style="color: #000000">!=</span><span style="color: #000000">'</span><span style="color: #000000">\0</span><span style="color: #000000">'</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">||</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">(str2</span><span style="color: #000000">+</span><span style="color: #000000">i)</span><span style="color: #000000">!=</span><span style="color: #000000">'</span><span style="color: #000000">\0</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img id="Codehighlighter1_869_1100_Open_Image" onclick="this.style.display='none'; Codehighlighter1_869_1100_Open_Text.style.display='none'; Codehighlighter1_869_1100_Closed_Image.style.display='inline'; Codehighlighter1_869_1100_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_869_1100_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_869_1100_Closed_Text.style.display='none'; Codehighlighter1_869_1100_Open_Image.style.display='inline'; Codehighlighter1_869_1100_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_869_1100_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_869_1100_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(</span><span style="color: #000000">*</span><span style="color: #000000">(str1</span><span style="color: #000000">+</span><span style="color: #000000">i)</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">\0</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img id="Codehighlighter1_896_940_Open_Image" onclick="this.style.display='none'; Codehighlighter1_896_940_Open_Text.style.display='none'; Codehighlighter1_896_940_Closed_Image.style.display='inline'; Codehighlighter1_896_940_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_896_940_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_896_940_Closed_Text.style.display='none'; Codehighlighter1_896_940_Open_Image.style.display='inline'; Codehighlighter1_896_940_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_896_940_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_896_940_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">(str1</span><span style="color: #000000">+</span><span style="color: #000000">i)</span><span style="color: #000000">=</span><span style="color: #000000">'</span><span style="color: #000000">0</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">(str1</span><span style="color: #000000">+</span><span style="color: #000000">i</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">)</span><span style="color: #000000">=</span><span style="color: #000000">'</span><span style="color: #000000">\0</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(</span><span style="color: #000000">*</span><span style="color: #000000">(str2</span><span style="color: #000000">+</span><span style="color: #000000">i)</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">\0</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img id="Codehighlighter1_967_1011_Open_Image" onclick="this.style.display='none'; Codehighlighter1_967_1011_Open_Text.style.display='none'; Codehighlighter1_967_1011_Closed_Image.style.display='inline'; Codehighlighter1_967_1011_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_967_1011_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_967_1011_Closed_Text.style.display='none'; Codehighlighter1_967_1011_Open_Image.style.display='inline'; Codehighlighter1_967_1011_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_967_1011_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_967_1011_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">(str2</span><span style="color: #000000">+</span><span style="color: #000000">i)</span><span style="color: #000000">=</span><span style="color: #000000">'</span><span style="color: #000000">0</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">(str2</span><span style="color: #000000">+</span><span style="color: #000000">i</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">)</span><span style="color: #000000">=</span><span style="color: #000000">'</span><span style="color: #000000">\0</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tmp</span><span style="color: #000000">=*</span><span style="color: #000000">(str1</span><span style="color: #000000">+</span><span style="color: #000000">i)</span><span style="color: #000000">-</span><span style="color: #000000">'</span><span style="color: #000000">0</span><span style="color: #000000">'</span><span style="color: #000000">+</span><span style="color: #000000">(</span><span style="color: #000000">*</span><span style="color: #000000">(str2</span><span style="color: #000000">+</span><span style="color: #000000">i)</span><span style="color: #000000">-</span><span style="color: #000000">'</span><span style="color: #000000">0</span><span style="color: #000000">'</span><span style="color: #000000">)</span><span style="color: #000000">+</span><span style="color: #000000">dec;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">(str1</span><span style="color: #000000">+</span><span style="color: #000000">i)</span><span style="color: #000000">=</span><span style="color: #000000">tmp</span><span style="color: #000000">%</span><span style="color: #000000">10</span><span style="color: #000000">+</span><span style="color: #000000">'</span><span style="color: #000000">0</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dec</span><span style="color: #000000">=</span><span style="color: #000000">tmp</span><span style="color: #000000">/</span><span style="color: #000000">10</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(dec</span><span style="color: #000000">!=</span><span style="color: #000000">0</span><span style="color: #000000">)&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">(str1</span><span style="color: #000000">+</span><span style="color: #000000">(i</span><span style="color: #000000">++</span><span style="color: #000000">))</span><span style="color: #000000">=</span><span style="color: #000000">dec</span><span style="color: #000000">+</span><span style="color: #000000">'</span><span style="color: #000000">0</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">(str1</span><span style="color: #000000">+</span><span style="color: #000000">i)</span><span style="color: #000000">=</span><span style="color: #000000">'</span><span style="color: #000000">\0</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;strRevg(str1);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span></div>
<p><br /><br /></p></div><img src ="http://www.cppblog.com/codepeng/aggbug/155171.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/codepeng/" target="_blank">acpeng</a> 2011-09-05 23:22 <a href="http://www.cppblog.com/codepeng/archive/2011/09/05/155171.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ZOJ 1061  Web Navigation_数据结构_栈</title><link>http://www.cppblog.com/codepeng/archive/2011/09/05/155165.html</link><dc:creator>acpeng</dc:creator><author>acpeng</author><pubDate>Mon, 05 Sep 2011 14:47:00 GMT</pubDate><guid>http://www.cppblog.com/codepeng/archive/2011/09/05/155165.html</guid><wfw:comment>http://www.cppblog.com/codepeng/comments/155165.html</wfw:comment><comments>http://www.cppblog.com/codepeng/archive/2011/09/05/155165.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/codepeng/comments/commentRss/155165.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/codepeng/services/trackbacks/155165.html</trackback:ping><description><![CDATA[<a href="http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=61">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=61</a><br />数据结构，用C写的栈，不用STL确实复杂多了，WA了几次~<br />Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be reached by moving backward and forward. In this problem, you are asked to implement this. 
<p>The following commands need to be supported:</p>
<p><strong>BACK</strong>: Push the current page on the top of the forward stack. Pop the page from the top of the backward stack, making it the new current page. If the backward stack is empty, the command is ignored.</p>
<p><strong>FORWARD</strong>: Push the current page on the top of the backward stack. Pop the page from the top of the forward stack, making it the new current page. If the forward stack is empty, the command is ignored.</p>
<p><strong>VISIT &lt;url&gt;</strong>: Push the current page on the top of the backward stack, and make the URL specified the new current page. The forward stack is emptied.</p>
<p><strong>QUIT</strong>: Quit the browser.</p>
<p>Assume that the browser initially loads the web page at the URL http://www.acm.org/<br /><br /></p>
<p><br /><strong>This problem contains multiple test cases!</strong></p>
<p>The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.</p>
<p>The output format consists of N output blocks. There is a blank line between output blocks.</p>
<p><br /><strong>Input</strong></p>
<p>Input is a sequence of commands. The command keywords BACK, FORWARD, VISIT, and QUIT are all in uppercase. URLs have no whitespace and have at most 70 characters. You may assume that no problem instance requires more than 100 elements in each stack at any time. The end of input is indicated by the QUIT command.<br /><br /></p>
<p><strong>Output</strong></p>
<p>For each command other than QUIT, print the URL of the current page after the command is executed if the command is not ignored. Otherwise, print "Ignored". The output for each command should be printed on its own line. No output is produced for the QUIT command.<br /><br /></p>
<p><strong>Sample Input</strong></p>
<p>1</p>
<p>VISIT http://acm.ashland.edu/<br />VISIT http://acm.baylor.edu/acmicpc/<br />BACK<br />BACK<br />BACK<br />FORWARD<br />VISIT http://www.ibm.com/<br />BACK<br />BACK<br />FORWARD<br />FORWARD<br />FORWARD<br />QUIT<br /><br /></p>
<p><strong>Sample Output</strong></p>
<p>http://acm.ashland.edu/<br />http://acm.baylor.edu/acmicpc/<br />http://acm.ashland.edu/<br />http://www.acm.org/<br />Ignored<br />http://acm.ashland.edu/<br />http://www.ibm.com/<br />http://acm.ashland.edu/<br />http://www.acm.org/<br />http://acm.ashland.edu/<br />http://www.ibm.com/<br />Ignored<br /><br />AC代码：</p>
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #000000">#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">stdio.h</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#include</span><span style="color: #000000">&lt;</span><span style="color: #0000ff">string</span><span style="color: #000000">.h</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">malloc.h</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">#define</span><span style="color: #000000">&nbsp;StackSize&nbsp;105</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />typedef&nbsp;</span><span style="color: #0000ff">struct</span><span style="color: #000000"><br /><img id="Codehighlighter1_93_133_Open_Image" onclick="this.style.display='none'; Codehighlighter1_93_133_Open_Text.style.display='none'; Codehighlighter1_93_133_Closed_Image.style.display='inline'; Codehighlighter1_93_133_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_93_133_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_93_133_Closed_Text.style.display='none'; Codehighlighter1_93_133_Open_Image.style.display='inline'; Codehighlighter1_93_133_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_93_133_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_93_133_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;elemt[StackSize][</span><span style="color: #000000">73</span><span style="color: #000000">];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;top;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000">Stack;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;InitStack(Stack&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">S)<br /><img id="Codehighlighter1_166_182_Open_Image" onclick="this.style.display='none'; Codehighlighter1_166_182_Open_Text.style.display='none'; Codehighlighter1_166_182_Closed_Image.style.display='inline'; Codehighlighter1_166_182_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_166_182_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_166_182_Closed_Text.style.display='none'; Codehighlighter1_166_182_Open_Image.style.display='inline'; Codehighlighter1_166_182_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_166_182_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_166_182_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">top</span><span style="color: #000000">=-</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;ElemtNum(Stack&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">S)<br /><img id="Codehighlighter1_207_229_Open_Image" onclick="this.style.display='none'; Codehighlighter1_207_229_Open_Text.style.display='none'; Codehighlighter1_207_229_Closed_Image.style.display='inline'; Codehighlighter1_207_229_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_207_229_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_207_229_Closed_Text.style.display='none'; Codehighlighter1_207_229_Open_Image.style.display='inline'; Codehighlighter1_207_229_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_207_229_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_207_229_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;(S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">top)</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;IsFull(Stack&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">S)<br /><img id="Codehighlighter1_252_288_Open_Image" onclick="this.style.display='none'; Codehighlighter1_252_288_Open_Text.style.display='none'; Codehighlighter1_252_288_Closed_Image.style.display='inline'; Codehighlighter1_252_288_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_252_288_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_252_288_Closed_Text.style.display='none'; Codehighlighter1_252_288_Open_Image.style.display='inline'; Codehighlighter1_252_288_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_252_288_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_252_288_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">(S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">top</span><span style="color: #000000">==</span><span style="color: #000000">StackSize</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">?</span><span style="color: #000000">1</span><span style="color: #000000">:</span><span style="color: #000000">0</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;PushStack(Stack&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">S,</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">x)<br /><img id="Codehighlighter1_322_462_Open_Image" onclick="this.style.display='none'; Codehighlighter1_322_462_Open_Text.style.display='none'; Codehighlighter1_322_462_Closed_Image.style.display='inline'; Codehighlighter1_322_462_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_322_462_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_322_462_Closed_Text.style.display='none'; Codehighlighter1_322_462_Open_Image.style.display='inline'; Codehighlighter1_322_462_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_322_462_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_322_462_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(IsFull(S))&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">top</span><span style="color: #000000">++</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;memset(S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">elemt[S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">top],</span><span style="color: #000000">'</span><span style="color: #000000">\0</span><span style="color: #000000">'</span><span style="color: #000000">,</span><span style="color: #0000ff">sizeof</span><span style="color: #000000">(S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">elemt[S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">top]));<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;strcpy(S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">elemt[S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">top],x);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;PopStack(Stack&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">S,</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">x)<br /><img id="Codehighlighter1_495_664_Open_Image" onclick="this.style.display='none'; Codehighlighter1_495_664_Open_Text.style.display='none'; Codehighlighter1_495_664_Closed_Image.style.display='inline'; Codehighlighter1_495_664_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_495_664_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_495_664_Closed_Text.style.display='none'; Codehighlighter1_495_664_Open_Image.style.display='inline'; Codehighlighter1_495_664_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_495_664_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_495_664_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(ElemtNum(S)</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;memset(x,</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #0000ff">sizeof</span><span style="color: #000000">(x));<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strcpy(x,S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">elemt[S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">top]);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;memset(S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">elemt[S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">top],</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #0000ff">sizeof</span><span style="color: #000000">(S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">elemt[S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">top]));<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">top</span><span style="color: #000000">--</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;GetTopElemt(Stack&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">S,</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">x)<br /><img id="Codehighlighter1_700_804_Open_Image" onclick="this.style.display='none'; Codehighlighter1_700_804_Open_Text.style.display='none'; Codehighlighter1_700_804_Closed_Image.style.display='inline'; Codehighlighter1_700_804_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_700_804_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_700_804_Closed_Text.style.display='none'; Codehighlighter1_700_804_Open_Image.style.display='inline'; Codehighlighter1_700_804_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_700_804_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_700_804_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(ElemtNum(S)</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset(x,</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #0000ff">sizeof</span><span style="color: #000000">(x));<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strcpy(x,S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">elemt[S</span><span style="color: #000000">-&gt;</span><span style="color: #000000">top]);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_817_1936_Open_Image" onclick="this.style.display='none'; Codehighlighter1_817_1936_Open_Text.style.display='none'; Codehighlighter1_817_1936_Closed_Image.style.display='inline'; Codehighlighter1_817_1936_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_817_1936_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_817_1936_Closed_Text.style.display='none'; Codehighlighter1_817_1936_Open_Image.style.display='inline'; Codehighlighter1_817_1936_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_817_1936_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_817_1936_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;Stack&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">sBack,</span><span style="color: #000000">*</span><span style="color: #000000">sForward;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;sBack</span><span style="color: #000000">=</span><span style="color: #000000">(Stack&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">)malloc(</span><span style="color: #0000ff">sizeof</span><span style="color: #000000">(Stack));<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;sForward</span><span style="color: #000000">=</span><span style="color: #000000">(Stack&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">)malloc(</span><span style="color: #0000ff">sizeof</span><span style="color: #000000">(Stack));<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;T;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;str[</span><span style="color: #000000">73</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">\0</span><span style="color: #000000">"</span><span style="color: #000000">,comd[</span><span style="color: #000000">8</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">\0</span><span style="color: #000000">"</span><span style="color: #000000">,tmp[</span><span style="color: #000000">73</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">\0</span><span style="color: #000000">"</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">T);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(T</span><span style="color: #000000">--</span><span style="color: #000000">)<br /><img id="Codehighlighter1_1010_1894_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1010_1894_Open_Text.style.display='none'; Codehighlighter1_1010_1894_Closed_Image.style.display='inline'; Codehighlighter1_1010_1894_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1010_1894_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1010_1894_Closed_Text.style.display='none'; Codehighlighter1_1010_1894_Open_Image.style.display='inline'; Codehighlighter1_1010_1894_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1010_1894_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1010_1894_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InitStack(sBack);&nbsp;InitStack(sForward);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PushStack(sBack,</span><span style="color: #000000">"</span><span style="color: #000000">http://www.acm.org/</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(</span><span style="color: #000000">1</span><span style="color: #000000">)<br /><img id="Codehighlighter1_1108_1866_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1108_1866_Open_Text.style.display='none'; Codehighlighter1_1108_1866_Closed_Image.style.display='inline'; Codehighlighter1_1108_1866_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1108_1866_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1108_1866_Closed_Text.style.display='none'; Codehighlighter1_1108_1866_Open_Image.style.display='inline'; Codehighlighter1_1108_1866_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1108_1866_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1108_1866_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset(comd,</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #0000ff">sizeof</span><span style="color: #000000">(comd));<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%s</span><span style="color: #000000">"</span><span style="color: #000000">,comd);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(strcmp(comd,</span><span style="color: #000000">"</span><span style="color: #000000">BACK</span><span style="color: #000000">"</span><span style="color: #000000">)</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)<br /><img id="Codehighlighter1_1196_1396_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1196_1396_Open_Text.style.display='none'; Codehighlighter1_1196_1396_Closed_Image.style.display='inline'; Codehighlighter1_1196_1396_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1196_1396_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1196_1396_Closed_Text.style.display='none'; Codehighlighter1_1196_1396_Open_Image.style.display='inline'; Codehighlighter1_1196_1396_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1196_1396_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1196_1396_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(ElemtNum(sBack)</span><span style="color: #000000">==</span><span style="color: #000000">1</span><span style="color: #000000">)<br /><img id="Codehighlighter1_1229_1277_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1229_1277_Open_Text.style.display='none'; Codehighlighter1_1229_1277_Closed_Image.style.display='inline'; Codehighlighter1_1229_1277_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1229_1277_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1229_1277_Closed_Text.style.display='none'; Codehighlighter1_1229_1277_Open_Image.style.display='inline'; Codehighlighter1_1229_1277_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1229_1277_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1229_1277_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">Ignored\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">continue</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PopStack(sBack,tmp);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PushStack(sForward,tmp);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(GetTopElemt(sBack,tmp)</span><span style="color: #000000">==</span><span style="color: #000000">1</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%s\n</span><span style="color: #000000">"</span><span style="color: #000000">,tmp);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(strcmp(comd,</span><span style="color: #000000">"</span><span style="color: #000000">FORWARD</span><span style="color: #000000">"</span><span style="color: #000000">)</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)<br /><img id="Codehighlighter1_1439_1642_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1439_1642_Open_Text.style.display='none'; Codehighlighter1_1439_1642_Closed_Image.style.display='inline'; Codehighlighter1_1439_1642_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1439_1642_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1439_1642_Closed_Text.style.display='none'; Codehighlighter1_1439_1642_Open_Image.style.display='inline'; Codehighlighter1_1439_1642_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1439_1642_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1439_1642_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(ElemtNum(sForward)</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)<br /><img id="Codehighlighter1_1475_1523_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1475_1523_Open_Text.style.display='none'; Codehighlighter1_1475_1523_Closed_Image.style.display='inline'; Codehighlighter1_1475_1523_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1475_1523_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1475_1523_Closed_Text.style.display='none'; Codehighlighter1_1475_1523_Open_Image.style.display='inline'; Codehighlighter1_1475_1523_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1475_1523_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1475_1523_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">Ignored\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">continue</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PopStack(sForward,tmp);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PushStack(sBack,tmp);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(GetTopElemt(sBack,tmp)</span><span style="color: #000000">==</span><span style="color: #000000">1</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%s\n</span><span style="color: #000000">"</span><span style="color: #000000">,tmp);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(strcmp(comd,</span><span style="color: #000000">"</span><span style="color: #000000">VISIT</span><span style="color: #000000">"</span><span style="color: #000000">)</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)<br /><img id="Codehighlighter1_1683_1816_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1683_1816_Open_Text.style.display='none'; Codehighlighter1_1683_1816_Closed_Image.style.display='inline'; Codehighlighter1_1683_1816_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1683_1816_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1683_1816_Closed_Text.style.display='none'; Codehighlighter1_1683_1816_Open_Image.style.display='inline'; Codehighlighter1_1683_1816_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1683_1816_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1683_1816_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset(str,</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #0000ff">sizeof</span><span style="color: #000000">(str));<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%s</span><span style="color: #000000">"</span><span style="color: #000000">,str);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%s\n</span><span style="color: #000000">"</span><span style="color: #000000">,str);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PushStack(sBack,str);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InitStack(sForward);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(strcmp(comd,</span><span style="color: #000000">"</span><span style="color: #000000">QUIT</span><span style="color: #000000">"</span><span style="color: #000000">)</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">break</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(T</span><span style="color: #000000">&gt;</span><span style="color: #000000">0</span><span style="color: #000000">)&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;free(sBack);free(sForward);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span></div>
<p><br /></p><img src ="http://www.cppblog.com/codepeng/aggbug/155165.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/codepeng/" target="_blank">acpeng</a> 2011-09-05 22:47 <a href="http://www.cppblog.com/codepeng/archive/2011/09/05/155165.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU  1862 EXCEL排序</title><link>http://www.cppblog.com/codepeng/archive/2011/09/05/155160.html</link><dc:creator>acpeng</dc:creator><author>acpeng</author><pubDate>Mon, 05 Sep 2011 14:20:00 GMT</pubDate><guid>http://www.cppblog.com/codepeng/archive/2011/09/05/155160.html</guid><wfw:comment>http://www.cppblog.com/codepeng/comments/155160.html</wfw:comment><comments>http://www.cppblog.com/codepeng/archive/2011/09/05/155160.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/codepeng/comments/commentRss/155160.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/codepeng/services/trackbacks/155160.html</trackback:ping><description><![CDATA[<a href="http://acm.hdu.edu.cn/showproblem.php?pid=1862">http://acm.hdu.edu.cn/showproblem.php?pid=1862</a><br />结构体排序，C++的algorithm，写三个cmp即可<br />不过以这个数据的话，何必<span style="color: #008000"><strong>TimeLimit=5000ms</strong></span>~~
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #000000">#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">cstdio</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">cstring</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">algorithm</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;std;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />typedef&nbsp;</span><span style="color: #0000ff">struct</span><span style="color: #000000">&nbsp;infor<br /><img id="Codehighlighter1_97_143_Open_Image" onclick="this.style.display='none'; Codehighlighter1_97_143_Open_Text.style.display='none'; Codehighlighter1_97_143_Closed_Image.style.display='inline'; Codehighlighter1_97_143_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_97_143_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_97_143_Closed_Text.style.display='none'; Codehighlighter1_97_143_Open_Image.style.display='inline'; Codehighlighter1_97_143_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_97_143_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_97_143_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;stu_num[</span><span style="color: #000000">7</span><span style="color: #000000">];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;name[</span><span style="color: #000000">9</span><span style="color: #000000">];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;scor;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000">stu;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />stu&nbsp;data[</span><span style="color: #000000">100002</span><span style="color: #000000">];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;cmp1(stu&nbsp;a,stu&nbsp;b)<br /><img id="Codehighlighter1_189_246_Open_Image" onclick="this.style.display='none'; Codehighlighter1_189_246_Open_Text.style.display='none'; Codehighlighter1_189_246_Closed_Image.style.display='inline'; Codehighlighter1_189_246_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_189_246_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_189_246_Closed_Text.style.display='none'; Codehighlighter1_189_246_Open_Image.style.display='inline'; Codehighlighter1_189_246_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_189_246_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_189_246_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(strcmp(a.stu_num,b.stu_num)</span><span style="color: #000000">&lt;</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;cmp2(stu&nbsp;a,stu&nbsp;b)<br /><img id="Codehighlighter1_270_407_Open_Image" onclick="this.style.display='none'; Codehighlighter1_270_407_Open_Text.style.display='none'; Codehighlighter1_270_407_Closed_Image.style.display='inline'; Codehighlighter1_270_407_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_270_407_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_270_407_Closed_Text.style.display='none'; Codehighlighter1_270_407_Open_Image.style.display='inline'; Codehighlighter1_270_407_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_270_407_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_270_407_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(strcmp(a.name,b.name)</span><span style="color: #000000">&lt;</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(strcmp(a.name,b.name)</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)<br /><img id="Codehighlighter1_346_394_Open_Image" onclick="this.style.display='none'; Codehighlighter1_346_394_Open_Text.style.display='none'; Codehighlighter1_346_394_Closed_Image.style.display='inline'; Codehighlighter1_346_394_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_346_394_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_346_394_Closed_Text.style.display='none'; Codehighlighter1_346_394_Open_Image.style.display='inline'; Codehighlighter1_346_394_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_346_394_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_346_394_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(strcmp(a.stu_num,b.stu_num)</span><span style="color: #000000">&lt;</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;cmp3(stu&nbsp;a,stu&nbsp;b)<br /><img id="Codehighlighter1_431_548_Open_Image" onclick="this.style.display='none'; Codehighlighter1_431_548_Open_Text.style.display='none'; Codehighlighter1_431_548_Closed_Image.style.display='inline'; Codehighlighter1_431_548_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_431_548_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_431_548_Closed_Text.style.display='none'; Codehighlighter1_431_548_Open_Image.style.display='inline'; Codehighlighter1_431_548_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_431_548_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_431_548_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(a.scor</span><span style="color: #000000">&lt;</span><span style="color: #000000">b.scor)</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(a.scor</span><span style="color: #000000">==</span><span style="color: #000000">b.scor)<br /><img id="Codehighlighter1_487_535_Open_Image" onclick="this.style.display='none'; Codehighlighter1_487_535_Open_Text.style.display='none'; Codehighlighter1_487_535_Closed_Image.style.display='inline'; Codehighlighter1_487_535_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_487_535_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_487_535_Closed_Text.style.display='none'; Codehighlighter1_487_535_Open_Image.style.display='inline'; Codehighlighter1_487_535_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_487_535_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_487_535_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(strcmp(a.stu_num,b.stu_num)</span><span style="color: #000000">&lt;</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_561_934_Open_Image" onclick="this.style.display='none'; Codehighlighter1_561_934_Open_Text.style.display='none'; Codehighlighter1_561_934_Closed_Image.style.display='inline'; Codehighlighter1_561_934_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_561_934_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_561_934_Closed_Text.style.display='none'; Codehighlighter1_561_934_Open_Image.style.display='inline'; Codehighlighter1_561_934_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_561_934_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_561_934_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;n,c,i,test</span><span style="color: #000000">=</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">n,</span><span style="color: #000000">&amp;</span><span style="color: #000000">c),n)<br /><img id="Codehighlighter1_613_921_Open_Image" onclick="this.style.display='none'; Codehighlighter1_613_921_Open_Text.style.display='none'; Codehighlighter1_613_921_Closed_Image.style.display='inline'; Codehighlighter1_613_921_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_613_921_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_613_921_Closed_Text.style.display='none'; Codehighlighter1_613_921_Open_Image.style.display='inline'; Codehighlighter1_613_921_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_613_921_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_613_921_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;i</span><span style="color: #000000">&lt;</span><span style="color: #000000">n;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%s%s%d</span><span style="color: #000000">"</span><span style="color: #000000">,data[i].stu_num,data[i].name,</span><span style="color: #000000">&amp;</span><span style="color: #000000">data[i].scor);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(c</span><span style="color: #000000">==</span><span style="color: #000000">1</span><span style="color: #000000">)sort(data,data</span><span style="color: #000000">+</span><span style="color: #000000">n,cmp1);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(c</span><span style="color: #000000">==</span><span style="color: #000000">2</span><span style="color: #000000">)sort(data,data</span><span style="color: #000000">+</span><span style="color: #000000">n,cmp2);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;sort(data,data</span><span style="color: #000000">+</span><span style="color: #000000">n,cmp3);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">Case&nbsp;%d:\n</span><span style="color: #000000">"</span><span style="color: #000000">,test</span><span style="color: #000000">++</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;i</span><span style="color: #000000">&lt;</span><span style="color: #000000">n;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%s&nbsp;%s&nbsp;%d\n</span><span style="color: #000000">"</span><span style="color: #000000">,data[i].stu_num,data[i].name,data[i].scor);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span></div><br /><img src ="http://www.cppblog.com/codepeng/aggbug/155160.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/codepeng/" target="_blank">acpeng</a> 2011-09-05 22:20 <a href="http://www.cppblog.com/codepeng/archive/2011/09/05/155160.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>POJ 2273  An Excel-lent Problem</title><link>http://www.cppblog.com/codepeng/archive/2011/09/05/155158.html</link><dc:creator>acpeng</dc:creator><author>acpeng</author><pubDate>Mon, 05 Sep 2011 13:53:00 GMT</pubDate><guid>http://www.cppblog.com/codepeng/archive/2011/09/05/155158.html</guid><wfw:comment>http://www.cppblog.com/codepeng/comments/155158.html</wfw:comment><comments>http://www.cppblog.com/codepeng/archive/2011/09/05/155158.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/codepeng/comments/commentRss/155158.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/codepeng/services/trackbacks/155158.html</trackback:ping><description><![CDATA[<div class="plm"></div>
<p class="pst">把整数转化为excel对应的列值<a href="http://poj.org/problem?id=2273"><strong>http://poj.org/problem?id=2273</strong></a><br /><strong>Description</strong></p>
<div lang="en-US" class="ptx">A certain spreadsheet program labels the columns of a spreadsheet using letters. Column 1 is labeled as ``A", column 2 as ``B", ..., column 26 as ``Z". When the number of columns is greater than 26, another letter is used. For example, column 27 is ``AA", column 28 is ``AB" and column 52 is ``AZ". It follows that column 53 would be ``BA" and so on. Similarly, when column ``ZZ" is reached, the next column would be ``AAA", then ``AAB" and so on. <br /><br />The rows in the spreadsheet are labeled using the row number. Rows start at 1. <br /><br />The designation for a particular cell within the spreadsheet is created by combining the column label with the row label. For example, the upper-left most cell would be ``A1". The cell at column 55 row 23 would be ``BC23". <br /><br />You will write a program that converts numeric row and column values into the spreadsheet designation. </div>
<p class="pst"><strong style="color: #3366ff">Input</strong></p>
<div lang="en-US" class="ptx">Input consists of lines of the form: RnCm. n represents the row number [1,300000000] and m represents the column number, 1&lt;=m&lt;=300000000. The values n and m define a single cell on the spreadsheet. Input terminates with the line: R0C0 (that is, n and m are 0). There will be no leading zeroes or extra spaces in the input. <br /></div>
<p class="pst"><span style="color: #3366ff">Output</span></p>
<div lang="en-US" class="ptx">For each line of input (except the terminating line), you will print out the spreadsheet designation for the specified cell as described above.</div>
<p class="pst"><strong style="color: #ff0000">Sample Input</strong></p><pre class="sio">R1C1
R3C1
R1C3
R299999999C26
R52C52
R53C17576
R53C17602
R0C0
</pre>
<p class="pst"><span style="color: #ff0000"><strong>Sample Output</strong></span></p><pre class="sio">A1
A3
C1
Z299999999
AZ52
YYZ53
YZZ53
</pre>
<p class="pst"><strong style="color: #008000">Source</strong></p>
<div lang="en-US" class="ptx"><a href="http://poj.org/searchproblem?field=source&amp;key=Greater+New+York+2004">Greater New York 2004</a><br /><br />进制转化问题，把列数改成26进制输出，分别用A,B...Z代替1,2,3...这里base[0]='Z'，表示n与26余数为0时的取值，但进位问题需要注意，分余数是否为0两种情况分析。<br />代码： 
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /><span style="color: #000000">#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">stdio.h</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">#define</span><span style="color: #000000">&nbsp;R&nbsp;26</span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">base</span><span style="color: #000000">[</span><span style="color: #000000">30</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">ZABCDEFGHIJKLMNOPQRSTUVWXYZ</span><span style="color: #000000">"</span><span style="color: #000000">;<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;fun(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;N)<br /><img id="Codehighlighter1_92_259_Open_Image" onclick="this.style.display='none'; Codehighlighter1_92_259_Open_Text.style.display='none'; Codehighlighter1_92_259_Closed_Image.style.display='inline'; Codehighlighter1_92_259_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_92_259_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_92_259_Closed_Text.style.display='none'; Codehighlighter1_92_259_Open_Image.style.display='inline'; Codehighlighter1_92_259_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_92_259_Closed_Text"><img alt="" src="http://www.cppblog.com/Images/dot.gif" /></span><span id="Codehighlighter1_92_259_Open_Text"><span style="color: #000000">{<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">,j;&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;str[</span><span style="color: #000000">10</span><span style="color: #000000">];<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(N</span><span style="color: #000000">&gt;</span><span style="color: #000000">R)<br /><img id="Codehighlighter1_136_192_Open_Image" onclick="this.style.display='none'; Codehighlighter1_136_192_Open_Text.style.display='none'; Codehighlighter1_136_192_Closed_Image.style.display='inline'; Codehighlighter1_136_192_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_136_192_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_136_192_Closed_Text.style.display='none'; Codehighlighter1_136_192_Open_Image.style.display='inline'; Codehighlighter1_136_192_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_136_192_Closed_Text"><img alt="" src="http://www.cppblog.com/Images/dot.gif" /></span><span id="Codehighlighter1_136_192_Open_Text"><span style="color: #000000">{<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str[i</span><span style="color: #000000">++</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #0000ff">base</span><span style="color: #000000">[N</span><span style="color: #000000">%</span><span style="color: #000000">R];<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;N</span><span style="color: #000000">=</span><span style="color: #000000">N</span><span style="color: #000000">%</span><span style="color: #000000">R</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">?</span><span style="color: #000000">N</span><span style="color: #000000">/</span><span style="color: #000000">R</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">:N</span><span style="color: #000000">/</span><span style="color: #000000">R;<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;str[i]</span><span style="color: #000000">=</span><span style="color: #0000ff">base</span><span style="color: #000000">[N];<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(j</span><span style="color: #000000">=</span><span style="color: #000000">i;j</span><span style="color: #000000">&gt;=</span><span style="color: #000000">0</span><span style="color: #000000">;j</span><span style="color: #000000">--</span><span style="color: #000000">)<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%c</span><span style="color: #000000">"</span><span style="color: #000000">,str[j]);<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" />}</span></span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_272_409_Open_Image" onclick="this.style.display='none'; Codehighlighter1_272_409_Open_Text.style.display='none'; Codehighlighter1_272_409_Closed_Image.style.display='inline'; Codehighlighter1_272_409_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_272_409_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_272_409_Closed_Text.style.display='none'; Codehighlighter1_272_409_Open_Image.style.display='inline'; Codehighlighter1_272_409_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_272_409_Closed_Text"><img alt="" src="http://www.cppblog.com/Images/dot.gif" /></span><span id="Codehighlighter1_272_409_Open_Text"><span style="color: #000000">{<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;m,n;<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%*c%d%*c%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">m,</span><span style="color: #000000">&amp;</span><span style="color: #000000">n)</span><span style="color: #000000">!=</span><span style="color: #000000">EOF)<br /><img id="Codehighlighter1_324_396_Open_Image" onclick="this.style.display='none'; Codehighlighter1_324_396_Open_Text.style.display='none'; Codehighlighter1_324_396_Closed_Image.style.display='inline'; Codehighlighter1_324_396_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_324_396_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_324_396_Closed_Text.style.display='none'; Codehighlighter1_324_396_Open_Image.style.display='inline'; Codehighlighter1_324_396_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_324_396_Closed_Text"><img alt="" src="http://www.cppblog.com/Images/dot.gif" /></span><span id="Codehighlighter1_324_396_Open_Text"><span style="color: #000000">{<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getchar();<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(m</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">&nbsp;n</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #0000ff">break</span><span style="color: #000000">;<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fun(n);<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%d\n</span><span style="color: #000000">"</span><span style="color: #000000">,m);<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img alt="" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" />}</span></span></div><br /></div><img src ="http://www.cppblog.com/codepeng/aggbug/155158.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/codepeng/" target="_blank">acpeng</a> 2011-09-05 21:53 <a href="http://www.cppblog.com/codepeng/archive/2011/09/05/155158.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 1166敌兵布阵</title><link>http://www.cppblog.com/codepeng/archive/2011/09/01/154891.html</link><dc:creator>acpeng</dc:creator><author>acpeng</author><pubDate>Thu, 01 Sep 2011 09:14:00 GMT</pubDate><guid>http://www.cppblog.com/codepeng/archive/2011/09/01/154891.html</guid><wfw:comment>http://www.cppblog.com/codepeng/comments/154891.html</wfw:comment><comments>http://www.cppblog.com/codepeng/archive/2011/09/01/154891.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/codepeng/comments/commentRss/154891.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/codepeng/services/trackbacks/154891.html</trackback:ping><description><![CDATA[<div>题目链接：<a href="http://acm.hdu.edu.cn/showproblem.php?pid=1166">http://acm.hdu.edu.cn/showproblem.php?pid=1166</a><br />初学线段树，本想些个树，写了一半实在是觉得没必要，此题直接用数组模拟，果断AC，1Y~~~
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #000000">#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">stdio.h</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#include</span><span style="color: #000000">&lt;</span><span style="color: #0000ff">string</span><span style="color: #000000">.h</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;data[</span><span style="color: #000000">50003</span><span style="color: #000000">];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_65_629_Open_Image" onclick="this.style.display='none'; Codehighlighter1_65_629_Open_Text.style.display='none'; Codehighlighter1_65_629_Closed_Image.style.display='inline'; Codehighlighter1_65_629_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_65_629_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_65_629_Closed_Text.style.display='none'; Codehighlighter1_65_629_Open_Image.style.display='inline'; Codehighlighter1_65_629_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_65_629_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_65_629_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;T,N,i,cont</span><span style="color: #000000">=</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;cd_1,cd_2,sum;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;comd[</span><span style="color: #000000">7</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">\0</span><span style="color: #000000">"</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">T);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(T</span><span style="color: #000000">--</span><span style="color: #000000">)<br /><img id="Codehighlighter1_157_616_Open_Image" onclick="this.style.display='none'; Codehighlighter1_157_616_Open_Text.style.display='none'; Codehighlighter1_157_616_Closed_Image.style.display='inline'; Codehighlighter1_157_616_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_157_616_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_157_616_Closed_Text.style.display='none'; Codehighlighter1_157_616_Open_Image.style.display='inline'; Codehighlighter1_157_616_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_157_616_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_157_616_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">N);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">Case&nbsp;%d:\n</span><span style="color: #000000">"</span><span style="color: #000000">,cont);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cont</span><span style="color: #000000">++</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;i</span><span style="color: #000000">&lt;</span><span style="color: #000000">N;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">data[i]);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%s</span><span style="color: #000000">"</span><span style="color: #000000">,comd);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(strcmp(comd,</span><span style="color: #000000">"</span><span style="color: #000000">End</span><span style="color: #000000">"</span><span style="color: #000000">)</span><span style="color: #000000">!=</span><span style="color: #000000">0</span><span style="color: #000000">)<br /><img id="Codehighlighter1_314_613_Open_Image" onclick="this.style.display='none'; Codehighlighter1_314_613_Open_Text.style.display='none'; Codehighlighter1_314_613_Closed_Image.style.display='inline'; Codehighlighter1_314_613_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_314_613_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_314_613_Closed_Text.style.display='none'; Codehighlighter1_314_613_Open_Image.style.display='inline'; Codehighlighter1_314_613_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_314_613_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_314_613_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">cd_1,</span><span style="color: #000000">&amp;</span><span style="color: #000000">cd_2);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(comd[</span><span style="color: #000000">0</span><span style="color: #000000">]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">A</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data[cd_1</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">]</span><span style="color: #000000">+=</span><span style="color: #000000">cd_2;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(comd[</span><span style="color: #000000">0</span><span style="color: #000000">]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">S</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data[cd_1</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">]</span><span style="color: #000000">-=</span><span style="color: #000000">cd_2;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(comd[</span><span style="color: #000000">0</span><span style="color: #000000">]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">Q</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img id="Codehighlighter1_467_556_Open_Image" onclick="this.style.display='none'; Codehighlighter1_467_556_Open_Text.style.display='none'; Codehighlighter1_467_556_Closed_Image.style.display='inline'; Codehighlighter1_467_556_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_467_556_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_467_556_Closed_Text.style.display='none'; Codehighlighter1_467_556_Open_Image.style.display='inline'; Codehighlighter1_467_556_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_467_556_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_467_556_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">cd_1</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">;i</span><span style="color: #000000">&lt;</span><span style="color: #000000">cd_2;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum</span><span style="color: #000000">+=</span><span style="color: #000000">data[i];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%d\n</span><span style="color: #000000">"</span><span style="color: #000000">,sum);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset(comd,</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #0000ff">sizeof</span><span style="color: #000000">(comd));<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%s</span><span style="color: #000000">"</span><span style="color: #000000">,comd);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span></div><br /></div><img src ="http://www.cppblog.com/codepeng/aggbug/154891.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/codepeng/" target="_blank">acpeng</a> 2011-09-01 17:14 <a href="http://www.cppblog.com/codepeng/archive/2011/09/01/154891.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 1022  Train Problem I_数据结构_栈</title><link>http://www.cppblog.com/codepeng/archive/2011/08/26/154443.html</link><dc:creator>acpeng</dc:creator><author>acpeng</author><pubDate>Fri, 26 Aug 2011 10:04:00 GMT</pubDate><guid>http://www.cppblog.com/codepeng/archive/2011/08/26/154443.html</guid><wfw:comment>http://www.cppblog.com/codepeng/comments/154443.html</wfw:comment><comments>http://www.cppblog.com/codepeng/archive/2011/08/26/154443.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/codepeng/comments/commentRss/154443.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/codepeng/services/trackbacks/154443.html</trackback:ping><description><![CDATA[<div>题目地址：<a href="http://acm.hdu.edu.cn/showproblem.php?pid=1022">http://acm.hdu.edu.cn/showproblem.php?pid=1022</a><br />
<div class="panel_title" align="left"><strong style="color: #0000ff">Problem Description</strong></div>
<div class="panel_content">&nbsp;&nbsp;&nbsp;&nbsp; As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest all over the world ^v^). But here comes a problem, there is only one railway where all the trains stop. So all the trains come in from one side and get out from the other side. For this problem, if train A gets into the railway first, and then train B gets into the railway before train A leaves, train A can't leave until train B leaves. The pictures below figure out the problem. Now the problem for you is, there are at most 9 trains in the station, all the trains has an ID(numbered from 1 to n), the trains get into the railway in an order O1, your task is to determine whether the trains can get out in an order O2.<br /><img src="http://acm.hdu.edu.cn/data/images/1022-1.jpg"  alt="" /><img src="http://acm.hdu.edu.cn/data/images/1022-2.jpg"  alt="" /><img src="http://acm.hdu.edu.cn/data/images/1022-3.jpg"  alt="" /><br /></div>
<div class="panel_title" align="left"><strong style="color: #0000ff">Input</strong></div>
<div class="panel_content">The input contains several test cases. Each test case consists of an integer, the number of trains, and two strings, the order of the trains come in:O1, and the order of the trains leave:O2. The input is terminated by the end of file. More details in the Sample Input.</div>
<div class="panel_title" align="left"><span style="color: #0000ff"><strong>Output</strong></span></div>
<div class="panel_content">The output contains a string "No." if you can't exchange O2 to O1, or you should output a line contains "Yes.", and then output your way in exchanging the order(you should output "in" for a train getting into the railway, and "out" for a train getting out of the railway). Print a line contains "FINISH" after each test case. More details in the Sample Output.<br /></div>
<div class="panel_title" align="left"><span style="color: #0000ff"><strong>Sample Input</strong></span></div>
<div class="panel_content"><pre><div style="font-family: Courier New,Courier,monospace">3 123 321
3 123 312<br /></div></pre></div>
<div class="panel_title" align="left"><span style="color: #0000ff"><strong>Sample Output</strong></span></div>
<div class="panel_content"><pre><div style="font-family: Courier New,Courier,monospace">Yes.
in
in
in
out
out
out
FINISH
No.
FINISH
下面是代码，第一次使用C++的STL模板，用的很不熟练，不过没想到1Y就过了~~~YY。。。<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #000000">#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">cstdio</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">stack</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;std;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_65_965_Open_Image" onclick="this.style.display='none'; Codehighlighter1_65_965_Open_Text.style.display='none'; Codehighlighter1_65_965_Closed_Image.style.display='inline'; Codehighlighter1_65_965_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_65_965_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_65_965_Closed_Text.style.display='none'; Codehighlighter1_65_965_Open_Image.style.display='inline'; Codehighlighter1_65_965_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_65_965_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_65_965_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i,j,k,n,ok,flg[</span><span style="color: #000000">22</span><span style="color: #000000">];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">in</span><span style="color: #000000">[</span><span style="color: #000000">10</span><span style="color: #000000">],</span><span style="color: #0000ff">out</span><span style="color: #000000">[</span><span style="color: #000000">10</span><span style="color: #000000">];<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">n)</span><span style="color: #000000">!=</span><span style="color: #000000">EOF)<br /><img id="Codehighlighter1_155_949_Open_Image" onclick="this.style.display='none'; Codehighlighter1_155_949_Open_Text.style.display='none'; Codehighlighter1_155_949_Closed_Image.style.display='inline'; Codehighlighter1_155_949_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_155_949_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_155_949_Closed_Text.style.display='none'; Codehighlighter1_155_949_Open_Image.style.display='inline'; Codehighlighter1_155_949_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_155_949_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_155_949_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%s%s</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #0000ff">in</span><span style="color: #000000">,</span><span style="color: #0000ff">out</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stack</span><span style="color: #000000">&lt;</span><span style="color: #0000ff">int</span><span style="color: #000000">&gt;</span><span style="color: #000000">&nbsp;s;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i</span><span style="color: #000000">=</span><span style="color: #000000">j</span><span style="color: #000000">=</span><span style="color: #000000">k</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;ok</span><span style="color: #000000">=</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(j</span><span style="color: #000000">&lt;</span><span style="color: #000000">n)<br /><img id="Codehighlighter1_258_673_Open_Image" onclick="this.style.display='none'; Codehighlighter1_258_673_Open_Text.style.display='none'; Codehighlighter1_258_673_Closed_Image.style.display='inline'; Codehighlighter1_258_673_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_258_673_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_258_673_Closed_Text.style.display='none'; Codehighlighter1_258_673_Open_Image.style.display='inline'; Codehighlighter1_258_673_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_258_673_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_258_673_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(</span><span style="color: #0000ff">in</span><span style="color: #000000">[i]</span><span style="color: #000000">==</span><span style="color: #0000ff">out</span><span style="color: #000000">[j])<br /><img id="Codehighlighter1_302_363_Open_Image" onclick="this.style.display='none'; Codehighlighter1_302_363_Open_Text.style.display='none'; Codehighlighter1_302_363_Closed_Image.style.display='inline'; Codehighlighter1_302_363_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_302_363_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_302_363_Closed_Text.style.display='none'; Codehighlighter1_302_363_Open_Image.style.display='inline'; Codehighlighter1_302_363_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_302_363_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_302_363_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flg[k</span><span style="color: #000000">++</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;flg[k</span><span style="color: #000000">++</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #000000">1</span><span style="color: #000000">;i</span><span style="color: #000000">++</span><span style="color: #000000">;j</span><span style="color: #000000">++</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(</span><span style="color: #000000">!</span><span style="color: #000000">s.empty()&nbsp;</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">&nbsp;s.top()</span><span style="color: #000000">==</span><span style="color: #000000">(</span><span style="color: #0000ff">out</span><span style="color: #000000">[j]</span><span style="color: #000000">-</span><span style="color: #000000">'</span><span style="color: #000000">0</span><span style="color: #000000">'</span><span style="color: #000000">))<br /><img id="Codehighlighter1_434_488_Open_Image" onclick="this.style.display='none'; Codehighlighter1_434_488_Open_Text.style.display='none'; Codehighlighter1_434_488_Closed_Image.style.display='inline'; Codehighlighter1_434_488_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_434_488_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_434_488_Closed_Text.style.display='none'; Codehighlighter1_434_488_Open_Image.style.display='inline'; Codehighlighter1_434_488_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_434_488_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_434_488_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flg[k</span><span style="color: #000000">++</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #000000">1</span><span style="color: #000000">;s.pop();j</span><span style="color: #000000">++</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(i</span><span style="color: #000000">&lt;</span><span style="color: #000000">n)<br /><img id="Codehighlighter1_527_589_Open_Image" onclick="this.style.display='none'; Codehighlighter1_527_589_Open_Text.style.display='none'; Codehighlighter1_527_589_Closed_Image.style.display='inline'; Codehighlighter1_527_589_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_527_589_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_527_589_Closed_Text.style.display='none'; Codehighlighter1_527_589_Open_Image.style.display='inline'; Codehighlighter1_527_589_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_527_589_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_527_589_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s.push(</span><span style="color: #0000ff">in</span><span style="color: #000000">[i</span><span style="color: #000000">++</span><span style="color: #000000">]</span><span style="color: #000000">-</span><span style="color: #000000">'</span><span style="color: #000000">0</span><span style="color: #000000">'</span><span style="color: #000000">);flg[k</span><span style="color: #000000">++</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;<br /><img id="Codehighlighter1_621_663_Open_Image" onclick="this.style.display='none'; Codehighlighter1_621_663_Open_Text.style.display='none'; Codehighlighter1_621_663_Closed_Image.style.display='inline'; Codehighlighter1_621_663_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_621_663_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_621_663_Closed_Text.style.display='none'; Codehighlighter1_621_663_Open_Image.style.display='inline'; Codehighlighter1_621_663_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_621_663_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_621_663_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ok</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;</span><span style="color: #0000ff">break</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(ok</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)printf(</span><span style="color: #000000">"</span><span style="color: #000000">No.\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000"><br /><img id="Codehighlighter1_731_914_Open_Image" onclick="this.style.display='none'; Codehighlighter1_731_914_Open_Text.style.display='none'; Codehighlighter1_731_914_Closed_Image.style.display='inline'; Codehighlighter1_731_914_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_731_914_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_731_914_Closed_Text.style.display='none'; Codehighlighter1_731_914_Open_Image.style.display='inline'; Codehighlighter1_731_914_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_731_914_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_731_914_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">Yes.\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(i</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;i</span><span style="color: #000000">&lt;</span><span style="color: #000000">k;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img id="Codehighlighter1_805_904_Open_Image" onclick="this.style.display='none'; Codehighlighter1_805_904_Open_Text.style.display='none'; Codehighlighter1_805_904_Closed_Image.style.display='inline'; Codehighlighter1_805_904_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_805_904_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_805_904_Closed_Text.style.display='none'; Codehighlighter1_805_904_Open_Image.style.display='inline'; Codehighlighter1_805_904_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_805_904_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_805_904_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(flg[i]</span><span style="color: #000000">==</span><span style="color: #000000">0</span><span style="color: #000000">)printf(</span><span style="color: #000000">"</span><span style="color: #000000">in\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">out\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">FINISH\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span></div><br /><br /></div></pre></div></div><img src ="http://www.cppblog.com/codepeng/aggbug/154443.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/codepeng/" target="_blank">acpeng</a> 2011-08-26 18:04 <a href="http://www.cppblog.com/codepeng/archive/2011/08/26/154443.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>