﻿<?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++博客-Naeioi</title><link>http://www.cppblog.com/Naeioi/</link><description>量子の風</description><language>zh-cn</language><lastBuildDate>Tue, 14 Apr 2026 23:08:10 GMT</lastBuildDate><pubDate>Tue, 14 Apr 2026 23:08:10 GMT</pubDate><ttl>60</ttl><item><title>栈-表达式求值</title><link>http://www.cppblog.com/Naeioi/archive/2011/10/22/158898.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Sat, 22 Oct 2011 15:12:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2011/10/22/158898.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/158898.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2011/10/22/158898.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/158898.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/158898.html</trackback:ping><description><![CDATA[&nbsp; &nbsp;所谓表达式求值就是用计算机计算加减乘除式子，说的装逼一点，就是计算中缀表达式的值。<br />&nbsp; &nbsp;<span style="font-family: sans-serif; font-size: 15px; line-height: 22px; ">5 + ((1 + 2) * 4) &#8722; 3<br /></span>&nbsp; &nbsp;我们把这个式子添上括号，保持计算顺序不变。<br />&nbsp; &nbsp;(<span style="font-family: sans-serif; font-size: 15px; line-height: 22px; background-color: #ffffff; ">5+((1+2)*4))-3)<br /></span>&nbsp; &nbsp;运算符夹在数字中间，&#8220;中缀&#8221;之名由此得来。<br />&nbsp; &nbsp;人脑可以很快判断计算先后顺序，其实这个过程不是那么显然。因为*/+-有优先级，括号的加入又会打破这个规则。我们可以找出一个式子中最后进行的一步运算，对它的两边分别计算，在根据运算符进行合并。<br />&nbsp; &nbsp;<span style="font-weight: bold; color: red; ">(</span><span style="font-weight: bold; font-family: sans-serif; font-size: 15px; line-height: 22px; background-color: #ffffff; color: red; ">5+((1+2)*4))</span><span style="font-weight: bold; font-family: sans-serif; font-size: 15px; line-height: 22px; background-color: #ffffff; ">-</span><span style="font-family: sans-serif; font-size: 15px; line-height: 22px; background-color: #ffffff; color: #000080; "><strong>3)</strong><br /><strong>&nbsp;&nbsp;</strong><br /></span><span style="font-family: sans-serif; font-size: 15px; line-height: 22px; background-color: #ffffff; color: #000000; ">下面挂的代码是递归实现的。不要骂我标题党，不久会更新真正的栈实现代码，这需要时间，时间~再说递归才符合思维习惯，也更便于记忆~！</span><span style="font-size: 13px; background-color: #eeeeee; color: #008000; ">//</span><span style="font-size: 13px; background-color: #eeeeee; color: #008000; ">表达式求值（递归实现）&nbsp;</span><span style="font-family: sans-serif; font-size: 15px; line-height: 22px; background-color: #ffffff; color: #000000; "><br /></span><div style="font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; background-color: #eeeeee; "><font color="#008000">/*</font><span style="color: #008000; ">Author:naeioi<br />Prog:C++&nbsp;<br />Time:11.10.22<br /></span><span style="color: #008000; ">*/</span><br />#include&nbsp;&lt;cstdio&gt;<br />#include&nbsp;&lt;cstring&gt;<br /><span style="color: #0000FF; ">using</span>&nbsp;<span style="color: #0000FF; ">namespace</span>&nbsp;std;<br /><br /><span style="color: #0000FF; ">const</span>&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;maxl=100;<br /><span style="color: #0000FF; ">char</span>&nbsp;s[maxl];<br /><br /><span style="color: #0000FF; ">#define</span>&nbsp;isnum(a)&nbsp;(a&gt;='0'&amp;&amp;a&lt;='9')<br /><span style="color: #0000FF; ">#define</span>&nbsp;isop(a)&nbsp;(a=='+'||a=='-'||a=='*'||a=='/')<br /><br /><span style="color: #0000FF; ">int</span>&nbsp;match(<span style="color: #0000FF; ">int</span>&nbsp;i)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;count=1;<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">while</span>(count!=0){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i++;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>(s[i]=='(')&nbsp;++count;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>(s[i]==')')&nbsp;--count;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;i;<br />}<br /><br /><span style="color: #0000FF; ">int</span>&nbsp;ston(<span style="color: #0000FF; ">int</span>&nbsp;p)<span style="color: #008000; ">//</span><span style="color: #008000; ">下标从p开始</span><span style="color: #008000; "><br /></span>{<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;ans=0,positive=1;<span style="color: #008000; ">//</span><span style="color: #008000; ">符号&nbsp;</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>(s[p]=='-'){++p;&nbsp;positive=-1;}<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">while</span>(isnum(s[p])){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans*=10;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans+=s[p++]-'0';<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;ans*positive;;<br />}<br /><br /><span style="color: #0000FF; ">int</span>&nbsp;div(<span style="color: #0000FF; ">int</span>&nbsp;l,<span style="color: #0000FF; ">int</span>&nbsp;r)<span style="color: #008000; ">//</span><span style="color: #008000; ">求l~r（下标）表示的式子的值&nbsp;</span><span style="color: #008000; "><br /></span>{<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">while</span>(s[l]=='('&amp;&amp;match(l)==r){++l;&nbsp;--r;}<span style="color: #008000; ">//</span><span style="color: #008000; ">去除多余括号。不能写成s[l]=='('&amp;&amp;s[r]=')'，形如(1+2)*(3+4)的式子会错误&nbsp;</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>(l&gt;r)&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;0;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;pos,prior=3;<span style="color: #008000; ">//</span><span style="color: #008000; ">优先级，2==*/,1==+-</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">for</span>(<span style="color: #0000FF; ">int</span>&nbsp;i=l;i&lt;=r;i++){<span style="color: #008000; ">//</span><span style="color: #008000; ">找优先级最小的运算符&nbsp;</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>(s[i]=='(')<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>((i=match(i)+1)&gt;r)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">break</span>;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>(s[i]=='*'||s[i]=='/')<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>(prior&gt;=2){pos=i;&nbsp;prior=2;}}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">else</span>&nbsp;<span style="color: #0000FF; ">if</span>(s[i]=='+'||s[i]=='-')<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>(prior&gt;=1&amp;&amp;i!=l&amp;&amp;!isop(s[i-1])){pos=i;&nbsp;prior=1;}<span style="color: #008000; ">//</span><span style="color: #008000; ">-接在运算符后时看成符号。否则看成减号&nbsp;</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>(prior==3)<span style="color: #008000; ">//</span><span style="color: #008000; ">是一个数</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;ston(l);&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;a=div(l,pos-1),b=div(pos+1,r),ans;<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">switch</span>(s[pos])<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">case</span>&nbsp;'+':<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans=a+b;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">break</span>;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">case</span>&nbsp;'-':<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans=a-b;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">break</span>;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">case</span>&nbsp;'*':<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans=a*b;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">break</span>;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">case</span>&nbsp;'/':<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans=a/b;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">break</span>;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;ans;<br />}<br /><br /><span style="color: #0000FF; ">int</span>&nbsp;main()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;freopen("eval.in","r",stdin);<br />&nbsp;&nbsp;&nbsp;&nbsp;freopen("eval.out","w",stdout);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;scanf("%s",s);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;printf("%d",div(0,strlen(s)-1));<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;fclose(stdin);<br />&nbsp;&nbsp;&nbsp;&nbsp;fclose(stdout);<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;0;<br />}</div><span style="font-family: sans-serif; font-size: 15px; line-height: 22px; background-color: #ffffff; color: #000080; "></span><img src ="http://www.cppblog.com/Naeioi/aggbug/158898.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2011-10-22 23:12 <a href="http://www.cppblog.com/Naeioi/archive/2011/10/22/158898.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>基本数据结构-高精度</title><link>http://www.cppblog.com/Naeioi/archive/2011/10/21/158844.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Fri, 21 Oct 2011 12:13:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2011/10/21/158844.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/158844.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2011/10/21/158844.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/158844.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/158844.html</trackback:ping><description><![CDATA[&nbsp; &nbsp; 下个月NOIP复试。初三一年奋战中考直升考，OI基本停滞。暑假宅在家里沉静于异世界也没怎么打代码，只帮人调了几个简单的程序，手生疏得很。于是打算用剩下一个月时间复习基本代码，建立一个标准代码库，让自己重新熟悉那些最最经典的算法实现，同时也为日后编码提供方便。<br />
&nbsp; &nbsp;这个标准代码库我都会亲自编码调试，努力保证正确性，力求简洁易读，注释完整。BUG在所难免，希望大家能在回复中帮助我改进XD.日后会不断更新各个方面（主要是涉及NOI）的基本代码。下面是预计的代码目录。<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
1.基本数据结构<br />
&nbsp; &nbsp;高精<br />
&nbsp; &nbsp;二分<br />
<div>&nbsp; &nbsp;哈希（也算查找）<br />
&nbsp; &nbsp;并查集<br />
&nbsp; &nbsp;队列、栈<br />
&nbsp; &nbsp; &nbsp; <font class="Apple-style-span" face="arial" size="2"><span class="Apple-style-span" style="line-height: 18px; font-size: 10pt; ">表达式计算</span></font></div>
2.排序、查找<br />
&nbsp; &nbsp;堆<br />
&nbsp; &nbsp;快排<br />
&nbsp; &nbsp;归并排序<br />
&nbsp; &nbsp;选排、插排、冒排（冒牌&#8230;&#8230;&#8230;）<br />
&nbsp; &nbsp;基数排序<br />
3.图论<br />
&nbsp; &nbsp;宽度、深度优先遍历<br />
&nbsp; &nbsp;Dijkstra、Floyd<br />
&nbsp; &nbsp;Prim、Kruskal<br />
&nbsp; &nbsp;SPFA<br />
&nbsp; &nbsp;最大流&amp;最小最小费用最大流<br />
4.其他<br />
（未完待补充）<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
高精度模板（无压位）<br />
<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #008000; ">//</span><span style="color: #008000; ">高精无压位</span><span style="color: #008000; "><br />
/*</span><span style="color: #008000; ">Author:naeioi<br />
Prog:C++<br />
Time:11-10-20<br />
</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br />
#include&nbsp;</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&nbsp;</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 />
</span><span style="color: #008000; ">//</span><span style="color: #008000; ">#include&nbsp;&lt;conio.h&gt;</span><span style="color: #008000; "><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;&nbsp;<br />
<br />
</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;maxlen</span><span style="color: #000000; ">=</span><span style="color: #000000; ">105</span><span style="color: #000000; ">+</span><span style="color: #000000; ">1</span><span style="color: #000000; ">;<br />
#ifndef&nbsp;max<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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; ">#endif</span><span style="color: #000000; "><br />
</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">结构说明&nbsp;<br />
1.len代表实际长度<br />
2.s[]从1开始&nbsp;逆序存储&nbsp;<br />
3.默认长度105&nbsp;<br />
</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br />
</span><span style="color: #008000; ">/*</span><span style="color: #008000; ">注意事项<br />
1.一定要将clear()函数放在赋值函数头，将数据清零<br />
2.&nbsp;赋值运算符优先级低，跟比较运算符在一起注意打括号<br />
3.基本函数定义形式<br />
&nbsp;&nbsp;&nbsp;Bign&nbsp;operator&nbsp;*(const&nbsp;Bign&nbsp;&amp;b)const{}<br />
&nbsp;&nbsp;&nbsp;注意返回Bign以及那两个const防改写&nbsp;<br />
4.&nbsp;函数都应写在struct里面<br />
</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br />
<br />
</span><span style="color: #0000FF; ">struct</span><span style="color: #000000; ">&nbsp;Bign{</span><span style="color: #008000; ">//</span><span style="color: #008000; ">函数后打</span><span style="color: #008000; ">//</span><span style="color: #008000; ">的是二级函数&nbsp;</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;len,s[maxlen];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">函数部分&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">初始化</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">&nbsp;clear(){len</span><span style="color: #000000; ">=</span><span style="color: #000000; ">1</span><span style="color: #000000; ">;memset(s,</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: #008000; ">//</span><span style="color: #008000; ">必要，赋值前必须清空&nbsp;</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign(){clear();}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">赋值</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000FF; ">char</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">a){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clear();</span><span style="color: #008000; ">//</span><span style="color: #008000; ">只需在此clear()，其他所有赋值函数都要调用它&nbsp;</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;len</span><span style="color: #000000; ">=</span><span style="color: #000000; ">strlen(a);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">for</span><span style="color: #000000; ">(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;i</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; ">len;i</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;s[i]</span><span style="color: #000000; ">=</span><span style="color: #000000; ">a[len</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 />
&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; ">*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;num){</span><span style="color: #008000; ">//</span><span style="color: #008000; ">用sprintf巧妙转化，减少代码量&nbsp;</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">char</span><span style="color: #000000; ">&nbsp;tmp[maxlen];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sprintf(tmp,</span><span style="color: #000000; ">"</span><span style="color: #000000; ">%d</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,num);<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; ">*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">=</span><span style="color: #000000; ">tmp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;num){</span><span style="color: #000000; ">*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">=</span><span style="color: #000000; ">num;}</span><span style="color: #008000; ">//<br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign(</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000FF; ">char</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">a){</span><span style="color: #000000; ">*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">=</span><span style="color: #000000; ">a;}</span><span style="color: #008000; ">//</span><span style="color: #008000; "><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">运算符<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">c++备注：形参const表示不改变形参，末尾const表示不改变*this.运算返回bign供操作</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">+</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">&nbsp;Bign&nbsp;</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">b)</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;c</span><span style="color: #000000; ">=*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.len</span><span style="color: #000000; ">=</span><span style="color: #000000; ">max(len,b.len);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">for</span><span style="color: #000000; ">(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;i</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; ">c.len;i</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;&nbsp;</span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">((c.s[i]</span><span style="color: #000000; ">+=</span><span style="color: #000000; ">b.s[i])&nbsp;</span><span style="color: #000000; ">&gt;=</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">10</span><span style="color: #000000; ">){</span><span style="color: #008000; ">//</span><span style="color: #008000; ">!!!赋值运算符比比较运算符优先度低!!!&nbsp;</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.s[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; ">c.s[i]</span><span style="color: #000000; ">/</span><span style="color: #000000; ">10</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;&nbsp;&nbsp;&nbsp;&nbsp;c.s[i]</span><span style="color: #000000; ">%=</span><span style="color: #000000; ">10</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;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">(c.s[c.len</span><span style="color: #000000; ">+</span><span style="color: #000000; ">1</span><span style="color: #000000; ">]</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">0</span><span style="color: #000000; ">)&nbsp;c.len</span><span style="color: #000000; ">++</span><span style="color: #000000; ">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;c;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">+=</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">&nbsp;Bign&nbsp;</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">b){<br />
&nbsp;&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; ">*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">=*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">+</span><span style="color: #000000; ">b);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span><span style="color: #008000; ">//<br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">+</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;b)</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;t</span><span style="color: #000000; ">=</span><span style="color: #000000; ">b;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;t</span><span style="color: #000000; ">+*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span><span style="color: #008000; ">//<br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">-</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">&nbsp;Bign&nbsp;</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">b)</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">{</span><span style="color: #008000; ">//</span><span style="color: #008000; ">须保证b比*this小&nbsp;</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;c</span><span style="color: #000000; ">=*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">for</span><span style="color: #000000; ">(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;i</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; ">len;i</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;&nbsp;</span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">((c.s[i]</span><span style="color: #000000; ">-=</span><span style="color: #000000; ">b.s[i])&nbsp;</span><span style="color: #000000; ">&lt;</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.s[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; ">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.s[i]</span><span style="color: #000000; ">+=</span><span style="color: #000000; ">10</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;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">while</span><span style="color: #000000; ">(c.s[c.len]</span><span style="color: #000000; ">==</span><span style="color: #000000; ">0</span><span style="color: #000000; ">)&nbsp;c.len</span><span style="color: #000000; ">--</span><span style="color: #000000; ">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;c;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">-</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;b)</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;t</span><span style="color: #000000; ">=</span><span style="color: #000000; ">b;<br />
&nbsp;&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; ">*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">-</span><span style="color: #000000; ">t;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span><span style="color: #008000; ">//<br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">&nbsp;Bign&nbsp;</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">b)</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;c;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.len</span><span style="color: #000000; ">=</span><span style="color: #000000; ">len</span><span style="color: #000000; ">+</span><span style="color: #000000; ">b.len;<br />
&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;</span><span style="color: #0000FF; ">for</span><span style="color: #000000; ">(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;i</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; ">len;i</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;&nbsp;</span><span style="color: #0000FF; ">for</span><span style="color: #000000; ">(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;j</span><span style="color: #000000; ">=</span><span style="color: #000000; ">1</span><span style="color: #000000; ">;j</span><span style="color: #000000; ">&lt;=</span><span style="color: #000000; ">b.len;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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">((c.s[i</span><span style="color: #000000; ">+</span><span style="color: #000000; ">j</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; ">s[i]&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">&nbsp;b.s[j])&nbsp;</span><span style="color: #000000; ">&gt;=</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">10</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.s[i</span><span style="color: #000000; ">+</span><span style="color: #000000; ">j]</span><span style="color: #000000; ">+=</span><span style="color: #000000; ">c.s[i</span><span style="color: #000000; ">+</span><span style="color: #000000; ">j</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; ">10</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.s[i</span><span style="color: #000000; ">+</span><span style="color: #000000; ">j</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; ">10</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">(c.s[c.len]</span><span style="color: #000000; ">==</span><span style="color: #000000; ">0</span><span style="color: #000000; ">)&nbsp;c.len</span><span style="color: #000000; ">--</span><span style="color: #000000; ">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;c;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">*=</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">&nbsp;Bign&nbsp;</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">b){<br />
&nbsp;&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; ">*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">=*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">*</span><span style="color: #000000; ">b);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span><span style="color: #008000; ">//<br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">/</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;b)</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">{</span><span style="color: #008000; ">//</span><span style="color: #008000; ">必须整除（TODO:另用函数实现取余)</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;t</span><span style="color: #000000; ">=*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">,c;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.len</span><span style="color: #000000; ">=</span><span style="color: #000000; ">len;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">for</span><span style="color: #000000; ">(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;i</span><span style="color: #000000; ">=</span><span style="color: #000000; ">len;i</span><span style="color: #000000; ">&gt;=</span><span style="color: #000000; ">1</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.s[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; ">(t.s[i]</span><span style="color: #000000; ">%</span><span style="color: #000000; ">b)</span><span style="color: #000000; ">*</span><span style="color: #000000; ">10</span><span style="color: #000000; ">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.s[i]</span><span style="color: #000000; ">=</span><span style="color: #000000; ">t.s[i]</span><span style="color: #000000; ">/</span><span style="color: #000000; ">b;<br />
&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;</span><span style="color: #0000FF; ">while</span><span style="color: #000000; ">(c.s[c.len]</span><span style="color: #000000; ">==</span><span style="color: #000000; ">0</span><span style="color: #000000; ">)&nbsp;c.len</span><span style="color: #000000; ">--</span><span style="color: #000000; ">;<br />
&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;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">remain=t.s[0];</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;c;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">%</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;b)</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;t</span><span style="color: #000000; ">=*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">,c;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.len</span><span style="color: #000000; ">=</span><span style="color: #000000; ">len;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">for</span><span style="color: #000000; ">(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;i</span><span style="color: #000000; ">=</span><span style="color: #000000; ">len;i</span><span style="color: #000000; ">&gt;=</span><span style="color: #000000; ">2</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.s[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; ">(t.s[i]</span><span style="color: #000000; ">%</span><span style="color: #000000; ">b)</span><span style="color: #000000; ">*</span><span style="color: #000000; ">10</span><span style="color: #000000; ">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.s[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; ">b;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">优化防溢出&nbsp;</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&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;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;t.s[</span><span style="color: #000000; ">1</span><span style="color: #000000; ">]</span><span style="color: #000000; ">%</span><span style="color: #000000; ">b;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">大小比较</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">bool</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">&nbsp;Bign&nbsp;</span><span style="color: #000000; ">&amp;</span><span style="color: #000000; ">b)</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">(len</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">b.len)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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; ">1</span><span style="color: #000000; ">;<br />
&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;</span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">(len</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">b.len)<br />
&nbsp;&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; ">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;&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;&nbsp;&nbsp;</span><span style="color: #0000FF; ">for</span><span style="color: #000000; ">(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;i</span><span style="color: #000000; ">=</span><span style="color: #000000; ">len;i</span><span style="color: #000000; ">&gt;=</span><span style="color: #000000; ">1</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">(s[i]</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">b.s[i])<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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; ">return</span><span style="color: #000000; ">&nbsp;</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;</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">bool</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000FF; ">operator</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">&nbsp;(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;b)</span><span style="color: #0000FF; ">const</span><span style="color: #000000; ">{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bign&nbsp;t</span><span style="color: #000000; ">=</span><span style="color: #000000; ">b;<br />
&nbsp;&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; ">*</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">t;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span><span style="color: #008000; ">//</span><span style="color: #008000; "><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">输出并换行&nbsp;</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">&nbsp;print(){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">for</span><span style="color: #000000; ">(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;i</span><span style="color: #000000; ">=</span><span style="color: #000000; ">len;i</span><span style="color: #000000; ">&gt;=</span><span style="color: #000000; ">1</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">%d</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,s[i]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">\n</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
};</span><span style="color: #008000; ">//</span><span style="color: #008000; ">OK<br />
</span></div><img src ="http://www.cppblog.com/Naeioi/aggbug/158844.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2011-10-21 20:13 <a href="http://www.cppblog.com/Naeioi/archive/2011/10/21/158844.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UVa 10115</title><link>http://www.cppblog.com/Naeioi/archive/2010/11/12/133463.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Fri, 12 Nov 2010 13:46:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2010/11/12/133463.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/133463.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2010/11/12/133463.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/133463.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/133463.html</trackback:ping><description><![CDATA[<a herf="http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;category=96&amp;page=show_problem&amp;problem=1056"><u>原题在这里.</u>小心指针!!!</a><div><a herf="http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;category=96&amp;page=show_problem&amp;problem=1056"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;cstdio&gt;</span>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;string.h&gt;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">using namespace</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> std</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">const int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">15</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">300</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> key</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">2</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">],</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">];</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> l</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">],</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">N</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">bool</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">match</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">s</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">k</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">while</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">k</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">s</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">!=*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">k</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return false</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">s</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">k</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return true</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">void</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">replace</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> cur</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]= {</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">};</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">memcpy</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">cur</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strcat</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">key</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strcat</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">+</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">cur</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">+</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">l</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">memcpy</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">sizeof</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">));</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">main</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">()</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#ifndef ONLINE_JUDGE</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">freopen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"10115.in"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"r"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdin</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">freopen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"10115.out"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"w"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdout</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#endif</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">while</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">scanf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"%d"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,&amp;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">N</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)&amp;&amp;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">N</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">!=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">memset</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">sizeof</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">));</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">getchar</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">();</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&lt;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">N</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">gets</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">key</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">gets</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">key</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            l</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strlen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">key</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">gets</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&lt;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">N</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">+</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">l</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]-</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">];</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">match</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">+</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">key</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]))</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">replace</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                    j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">puts</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">fclose</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdin</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">fclose</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdout</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre></a></div><img src ="http://www.cppblog.com/Naeioi/aggbug/133463.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2010-11-12 21:46 <a href="http://www.cppblog.com/Naeioi/archive/2010/11/12/133463.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UVa 644</title><link>http://www.cppblog.com/Naeioi/archive/2010/11/12/133459.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Fri, 12 Nov 2010 12:32:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2010/11/12/133459.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/133459.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2010/11/12/133459.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/133459.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/133459.html</trackback:ping><description><![CDATA[这道题交了4遍才AC,也不懂是什么原因<div><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;cstdio&gt;</span>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;string.h&gt;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">using namespace</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> std</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">const int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">20</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">],</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">];</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=-</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">count</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">main</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">()</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#ifndef ONLINE_JUDGE</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">freopen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"644.in"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"r"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdin</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">freopen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"644.out"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"w"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdout</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#endif</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0; background-color:#eeeeee;"></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">while</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">scanf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"%s"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[++</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">])==</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]!=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">'9'</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">continue</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">bool</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> is</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">true</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">--</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&lt;=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&amp;&amp;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">is</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&lt;=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&amp;&amp;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">is</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">!=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&amp;&amp;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strlen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">])&gt;=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strlen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]))</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">sprintf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"%.*s"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strlen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]),</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strcmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">])==</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                        is</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">false</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">printf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"Set %d is "</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,++</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">count</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">is</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">printf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"immediately decodable</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff00ff;">\n</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">else</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">printf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"not immediately decodable</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff00ff;">\n</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=-</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">fclose</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdin</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">fclose</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdout</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"></pre></div><img src ="http://www.cppblog.com/Naeioi/aggbug/133459.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2010-11-12 20:32 <a href="http://www.cppblog.com/Naeioi/archive/2010/11/12/133459.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UVa 10815</title><link>http://www.cppblog.com/Naeioi/archive/2010/11/12/133452.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Fri, 12 Nov 2010 11:13:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2010/11/12/133452.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/133452.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2010/11/12/133452.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/133452.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/133452.html</trackback:ping><description><![CDATA[<a href="http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;page=show_problem&amp;problem=1756">原题在这里</a>。代码写的比较乱

<div><a href="http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;page=show_problem&amp;problem=1756"></a><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;cstdio&gt;</span>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;string.h&gt;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;ctype.h&gt;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;stdlib.h&gt;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">using namespace</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> std</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">const int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">5005</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">205</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> word</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">],</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">];</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">bool</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">find</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">void</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&lt;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(!</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strcmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">word</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]))</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return true</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return false</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">cmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">const void</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">const void</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">b</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strcmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">((</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*)</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*)</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">b</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">main</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">()</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#ifndef ONLINE_JUDGE</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">freopen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"10815.in"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"r"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdin</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">freopen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"10815.out"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"w"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdout</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#endif</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(;;)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">do</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">getchar</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">();</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">while</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(!</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">isalpha</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)&amp;&amp;*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">!=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">EOF</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">scanf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"%[qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM]"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">+</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)==</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">EOF</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">break</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">];</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">tolower</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(!</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">find</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">())</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">memcpy</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">word</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++],</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">sizeof</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">));</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">qsort</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">word</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">sizeof</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">word</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]),</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">cmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&lt;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">printf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"%s</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff00ff;">\n</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">word</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">fclose</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdin</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">fclose</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdout</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"></pre></div><img src ="http://www.cppblog.com/Naeioi/aggbug/133452.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2010-11-12 19:13 <a href="http://www.cppblog.com/Naeioi/archive/2010/11/12/133452.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Uva 409</title><link>http://www.cppblog.com/Naeioi/archive/2010/11/11/133346.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Thu, 11 Nov 2010 11:19:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2010/11/11/133346.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/133346.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2010/11/11/133346.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/133346.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/133346.html</trackback:ping><description><![CDATA[<a href="http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;category=96&amp;page=show_problem&amp;problem=350">原题在这里</a>。字符串匹配，写起来稍稍有些繁琐<div><br></div><div><table id="Table1" class="tb" cellspacing="0" cellpadding="3" border="0" style="font-size: 13px; "><tbody><tr><td><pre><div><span style="color: rgb(0, 128, 128); "> 1</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">cstdio</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 2</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 255); ">string</span><span style="color: rgb(0, 0, 0); ">.h</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 3</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">ctype.h</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 4</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">vector</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 5</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">using</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">namespace</span><span style="color: rgb(0, 0, 0); "> std;
</span><span style="color: rgb(0, 128, 128); "> 6</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 7</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">const</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> maxk</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">100</span><span style="color: rgb(0, 0, 0); ">,maxl</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">100</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); "> 8</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">char</span><span style="color: rgb(0, 0, 0); "> key[maxk][maxl],str[maxl],str2[maxl],ans[maxk][maxl];
</span><span style="color: rgb(0, 128, 128); "> 9</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> K,E,n</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">,Max,l;
</span><span style="color: rgb(0, 128, 128); ">10</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">11</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">bool</span><span style="color: rgb(0, 0, 0); "> find(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> x,</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> y)
</span><span style="color: rgb(0, 128, 128); ">12</span> <span style="color: rgb(0, 0, 0); ">{
</span><span style="color: rgb(0, 128, 128); ">13</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;i</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">K;i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">){
</span><span style="color: rgb(0, 128, 128); ">14</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> j;
</span><span style="color: rgb(0, 128, 128); ">15</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(j</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;x</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">j</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">y</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">key[i][j];j</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">16</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(str[x</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">j]</span><span style="color: rgb(0, 0, 0); ">!=</span><span style="color: rgb(0, 0, 0); ">key[i][j])
</span><span style="color: rgb(0, 128, 128); ">17</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">break</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">18</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(x</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">j</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">y</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;!</span><span style="color: rgb(0, 0, 0); ">key[i][j])
</span><span style="color: rgb(0, 128, 128); ">19</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">return</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">true</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">20</span> <span style="color: rgb(0, 0, 0); ">    }
</span><span style="color: rgb(0, 128, 128); ">21</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">return</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">false</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">22</span> <span style="color: rgb(0, 0, 0); ">}
</span><span style="color: rgb(0, 128, 128); ">23</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">24</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> main()
</span><span style="color: rgb(0, 128, 128); ">25</span> <span style="color: rgb(0, 0, 0); ">{
</span><span style="color: rgb(0, 128, 128); ">26</span> <span style="color: rgb(0, 0, 0); ">    #ifndef ONLINE_JUDGE
</span><span style="color: rgb(0, 128, 128); ">27</span> <span style="color: rgb(0, 0, 0); ">    freopen(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">409.in</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">r</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,stdin);
</span><span style="color: rgb(0, 128, 128); ">28</span> <span style="color: rgb(0, 0, 0); ">    freopen(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">409.out</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">w</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,stdout);
</span><span style="color: rgb(0, 128, 128); ">29</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">#endif</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">30</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">31</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(scanf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%d%d</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">&amp;</span><span style="color: rgb(0, 0, 0); ">K,</span><span style="color: rgb(0, 0, 0); ">&amp;</span><span style="color: rgb(0, 0, 0); ">E)</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">2</span><span style="color: rgb(0, 0, 0); ">){
</span><span style="color: rgb(0, 128, 128); ">32</span> <span style="color: rgb(0, 0, 0); ">        l</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">Max</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">33</span> <span style="color: rgb(0, 0, 0); ">        printf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">Excuse Set #%d\\n</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">n);
</span><span style="color: rgb(0, 128, 128); ">34</span> <span style="color: rgb(0, 0, 0); ">        getchar();
</span><span style="color: rgb(0, 128, 128); ">35</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">36</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;i</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">K;i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">37</span> <span style="color: rgb(0, 0, 0); ">            gets(key[i]);
</span><span style="color: rgb(0, 128, 128); ">38</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;i</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">E;i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">){
</span><span style="color: rgb(0, 128, 128); ">39</span> <span style="color: rgb(0, 0, 0); ">            scanf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%[^\\r\\n]</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,str);
</span><span style="color: rgb(0, 128, 128); ">40</span> <span style="color: rgb(0, 0, 0); ">            memcpy(str2,str,</span><span style="color: rgb(0, 0, 255); ">sizeof</span><span style="color: rgb(0, 0, 0); ">(str));
</span><span style="color: rgb(0, 128, 128); ">41</span> <span style="color: rgb(0, 0, 0); ">            getchar();
</span><span style="color: rgb(0, 128, 128); ">42</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> a</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">,b,count</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">43</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(str[a]){
</span><span style="color: rgb(0, 128, 128); ">44</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 0); ">!</span><span style="color: rgb(0, 0, 0); ">isalpha(str[a])</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">str[a])</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">a;
</span><span style="color: rgb(0, 128, 128); ">45</span> <span style="color: rgb(0, 0, 0); ">                b</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">a;
</span><span style="color: rgb(0, 128, 128); ">46</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(isalpha(str[b])){str[b]</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">tolower(str[b]);</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">b;}
</span><span style="color: rgb(0, 128, 128); ">47</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(find(a,b</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">))count</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">48</span> <span style="color: rgb(0, 0, 0); ">                a</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">b;
</span><span style="color: rgb(0, 128, 128); ">49</span> <span style="color: rgb(0, 0, 0); ">            }
</span><span style="color: rgb(0, 128, 128); ">50</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(count</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">Max){
</span><span style="color: rgb(0, 128, 128); ">51</span> <span style="color: rgb(0, 0, 0); ">                Max</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">count;
</span><span style="color: rgb(0, 128, 128); ">52</span> <span style="color: rgb(0, 0, 0); ">                memset(ans,</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 255); ">sizeof</span><span style="color: rgb(0, 0, 0); ">(ans));
</span><span style="color: rgb(0, 128, 128); ">53</span> <span style="color: rgb(0, 0, 0); ">                l</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">54</span> <span style="color: rgb(0, 0, 0); ">                memcpy(ans[l</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">],str2,</span><span style="color: rgb(0, 0, 255); ">sizeof</span><span style="color: rgb(0, 0, 0); ">(str));
</span><span style="color: rgb(0, 128, 128); ">55</span> <span style="color: rgb(0, 0, 0); ">            }
</span><span style="color: rgb(0, 128, 128); ">56</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">else</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(count</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">Max)
</span><span style="color: rgb(0, 128, 128); ">57</span> <span style="color: rgb(0, 0, 0); ">                    memcpy(ans[l</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">],str2,</span><span style="color: rgb(0, 0, 255); ">sizeof</span><span style="color: rgb(0, 0, 0); ">(str));
</span><span style="color: rgb(0, 128, 128); ">58</span> <span style="color: rgb(0, 0, 0); ">        }
</span><span style="color: rgb(0, 128, 128); ">59</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;i</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">l;i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">60</span> <span style="color: rgb(0, 0, 0); ">            printf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%s\\n</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,ans[i]);
</span><span style="color: rgb(0, 128, 128); ">61</span> <span style="color: rgb(0, 0, 0); ">        printf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">\\n</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">);
</span><span style="color: rgb(0, 128, 128); ">62</span> <span style="color: rgb(0, 0, 0); ">    }
</span><span style="color: rgb(0, 128, 128); ">63</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">64</span> <span style="color: rgb(0, 0, 0); ">    fclose(stdin);
</span><span style="color: rgb(0, 128, 128); ">65</span> <span style="color: rgb(0, 0, 0); ">    fclose(stdout);
</span><span style="color: rgb(0, 128, 128); ">66</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">return</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">67</span> <span style="color: rgb(0, 0, 0); ">}
</span><span style="color: rgb(0, 128, 128); ">68</span> </div></pre></td></tr></tbody></table></div><img src ="http://www.cppblog.com/Naeioi/aggbug/133346.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2010-11-11 19:19 <a href="http://www.cppblog.com/Naeioi/archive/2010/11/11/133346.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UVa 537</title><link>http://www.cppblog.com/Naeioi/archive/2010/11/10/133228.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Wed, 10 Nov 2010 11:08:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2010/11/10/133228.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/133228.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2010/11/10/133228.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/133228.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/133228.html</trackback:ping><description><![CDATA[没什么好说的，锻炼编程能力，注意善用scanf :)<div><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 1</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">#include </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&lt;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">cstdio</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&gt;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 2</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "></span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">using</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">namespace</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> std;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 3</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 4</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "></span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">int</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> N;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 5</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "></span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">double</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">260</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">];
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 6</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 7</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "></span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">int</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> main()
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 8</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">{
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 9</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    #ifndef ONLINE_JUDGE
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">10</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    freopen(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">537.in</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">r</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,stdin);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">11</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    freopen(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">537.out</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">w</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,stdout);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">12</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">#endif</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">13</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">14</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    scanf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">%d</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">N);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">15</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    getchar();
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">16</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">17</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">for</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">int</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> i</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">1</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;i</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&lt;=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">N;i</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">++</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">){
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">18</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">U</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">I</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">P</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">0.0</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">19</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">for</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">int</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> j</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">0</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;j</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&lt;=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">1</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;j</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">++</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">){
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">20</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">            </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">char</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> last</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">getchar(),now;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">21</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">            </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">while</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">((now</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">getchar())</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">)last</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">now;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">22</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">            scanf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">%lf%c</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[last],</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">now);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">23</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">            </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">switch</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(now){
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">24</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">case</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">m</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">:
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">25</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                    a[last]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">/=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">1000.0</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">26</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                    </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">break</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">27</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">case</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">k</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">:
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">28</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                    a[last]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">*=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">1000.0</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">29</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                    </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">break</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">30</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">case</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">M</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">:
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">31</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                    a[last]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">*=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">1000000.0</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">32</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                    </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">break</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">33</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">            }
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">34</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        }
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">35</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">36</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        printf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Problem #%d\\n</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,i);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">37</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">38</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">U</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">I</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">])
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">39</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">           printf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">P=%.2lfW</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">U</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">*</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">I</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">40</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">else</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">U</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">P</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">])
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">41</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                printf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">I=%.2lfA</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">P</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">/</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">U</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">42</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">else</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">I</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">P</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">])
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">43</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                printf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">U=%.2lfV</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">P</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">/</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">I</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">44</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        printf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">\\n\\n</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">45</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    }
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">46</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">47</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    fclose(stdin);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">48</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    fclose(stdout);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">49</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">return</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">0</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">50</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">}
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">51</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span></div><img src ="http://www.cppblog.com/Naeioi/aggbug/133228.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2010-11-10 19:08 <a href="http://www.cppblog.com/Naeioi/archive/2010/11/10/133228.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UVa 10010</title><link>http://www.cppblog.com/Naeioi/archive/2010/11/07/132866.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Sun, 07 Nov 2010 08:36:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2010/11/07/132866.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/132866.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2010/11/07/132866.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/132866.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/132866.html</trackback:ping><description><![CDATA[

<span style="font-family: Arial; font-size: 14px; line-height: 21px; ">&nbsp;&nbsp;在一个n*m的字符矩阵中寻找给定的字符串，字符串可以是上下、下上、左右、右左等8个方向。输出每个字符串第一个字符首次出现的位置。</span><div style="font-family: Arial; font-size: 14px; line-height: 21px; ">要注意的是换行问题，对一个少一个都判作WA</div><div><font color="#008080" face="monospace" size="2"><span style="white-space: pre;"><span  style="color: rgb(0, 0, 0); font-size: 13px; "><span style="color: rgb(0, 128, 128); "> 1</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">cstdio</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 2</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 255); ">string</span><span style="color: rgb(0, 0, 0); ">.h</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 3</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">ctype.h</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 4</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">using</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">namespace</span><span style="color: rgb(0, 0, 0); "> std;
</span><span style="color: rgb(0, 128, 128); "> 5</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 6</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">const</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> maxn</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">60</span><span style="color: rgb(0, 0, 0); ">,dx[]</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> {</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">},dy[]</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> {</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">};
</span><span style="color: rgb(0, 128, 128); "> 7</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">char</span><span style="color: rgb(0, 0, 0); "> G[maxn][maxn];
</span><span style="color: rgb(0, 128, 128); "> 8</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> N,M,K;
</span><span style="color: rgb(0, 128, 128); "> 9</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">10</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> main()
</span><span style="color: rgb(0, 128, 128); ">11</span> <span style="color: rgb(0, 0, 0); ">{
</span><span style="color: rgb(0, 128, 128); ">12</span> <span style="color: rgb(0, 0, 0); ">#ifndef ONLINE_JUDGE
</span><span style="color: rgb(0, 128, 128); ">13</span> <span style="color: rgb(0, 0, 0); ">    freopen(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">10010.in</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">r</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,stdin);
</span><span style="color: rgb(0, 128, 128); ">14</span> <span style="color: rgb(0, 0, 0); ">    freopen(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">10010.out</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">w</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,stdout);
</span><span style="color: rgb(0, 128, 128); ">15</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">#endif</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">16</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">17</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> C,t</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">18</span> <span style="color: rgb(0, 0, 0); ">    scanf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%d</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">&amp;</span><span style="color: rgb(0, 0, 0); ">C);
</span><span style="color: rgb(0, 128, 128); ">19</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">20</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(C</span><span style="color: rgb(0, 0, 0); ">--</span><span style="color: rgb(0, 0, 0); ">) {
</span><span style="color: rgb(0, 128, 128); ">21</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(t</span><span style="color: rgb(0, 0, 0); ">!=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">)printf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">\\n</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">);
</span><span style="color: rgb(0, 128, 128); ">22</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">t;
</span><span style="color: rgb(0, 128, 128); ">23</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">24</span> <span style="color: rgb(0, 0, 0); ">        scanf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%d%d</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">&amp;</span><span style="color: rgb(0, 0, 0); ">N,</span><span style="color: rgb(0, 0, 0); ">&amp;</span><span style="color: rgb(0, 0, 0); ">M);
</span><span style="color: rgb(0, 128, 128); ">25</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">; i</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">N; i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">26</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> j</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">; j</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">M; j</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">) {
</span><span style="color: rgb(0, 128, 128); ">27</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">char</span><span style="color: rgb(0, 0, 0); "> tmp;
</span><span style="color: rgb(0, 128, 128); ">28</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">do</span><span style="color: rgb(0, 0, 0); "> {
</span><span style="color: rgb(0, 128, 128); ">29</span> <span style="color: rgb(0, 0, 0); ">                    tmp</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">getchar();
</span><span style="color: rgb(0, 128, 128); ">30</span> <span style="color: rgb(0, 0, 0); ">                }
</span><span style="color: rgb(0, 128, 128); ">31</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 0); ">!</span><span style="color: rgb(0, 0, 0); ">isalpha(tmp));
</span><span style="color: rgb(0, 128, 128); ">32</span> <span style="color: rgb(0, 0, 0); ">                G[i][j]</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">tolower(tmp);
</span><span style="color: rgb(0, 128, 128); ">33</span> <span style="color: rgb(0, 0, 0); ">            }
</span><span style="color: rgb(0, 128, 128); ">34</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">35</span> <span style="color: rgb(0, 0, 0); ">        scanf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%d</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">&amp;</span><span style="color: rgb(0, 0, 0); ">K);
</span><span style="color: rgb(0, 128, 128); ">36</span> <span style="color: rgb(0, 0, 0); ">        getchar();
</span><span style="color: rgb(0, 128, 128); ">37</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(K</span><span style="color: rgb(0, 0, 0); ">--</span><span style="color: rgb(0, 0, 0); ">) {
</span><span style="color: rgb(0, 128, 128); ">38</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">char</span><span style="color: rgb(0, 0, 0); "> str[maxn];
</span><span style="color: rgb(0, 128, 128); ">39</span> <span style="color: rgb(0, 0, 0); ">            gets(str);
</span><span style="color: rgb(0, 128, 128); ">40</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> len</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">strlen(str);
</span><span style="color: rgb(0, 128, 128); ">41</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">42</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">; i</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">len; i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">43</span> <span style="color: rgb(0, 0, 0); ">                str[i]</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">tolower(str[i]);
</span><span style="color: rgb(0, 128, 128); ">44</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">45</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">bool</span><span style="color: rgb(0, 0, 0); "> ok</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 255); ">false</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">46</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">; i</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">N</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;!</span><span style="color: rgb(0, 0, 0); ">ok; i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">47</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> j</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">; j</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">M</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;!</span><span style="color: rgb(0, 0, 0); ">ok; j</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">48</span> <span style="color: rgb(0, 0, 0); ">                    </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> k</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">; k</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">8</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;!</span><span style="color: rgb(0, 0, 0); ">ok; k</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">) {
</span><span style="color: rgb(0, 128, 128); ">49</span> <span style="color: rgb(0, 0, 0); ">                        </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> x</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">i,y</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">j,count</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">50</span> <span style="color: rgb(0, 0, 0); ">                        </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(x</span><span style="color: rgb(0, 0, 0); ">&gt;=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">y</span><span style="color: rgb(0, 0, 0); ">&gt;=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">x</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">N</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">y</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">M</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">count</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">len</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">str[count]</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">G[x][y]) {
</span><span style="color: rgb(0, 128, 128); ">51</span> <span style="color: rgb(0, 0, 0); ">                            </span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">count;
</span><span style="color: rgb(0, 128, 128); ">52</span> <span style="color: rgb(0, 0, 0); ">                            x</span><span style="color: rgb(0, 0, 0); ">+=</span><span style="color: rgb(0, 0, 0); ">dx[k];
</span><span style="color: rgb(0, 128, 128); ">53</span> <span style="color: rgb(0, 0, 0); ">                            y</span><span style="color: rgb(0, 0, 0); ">+=</span><span style="color: rgb(0, 0, 0); ">dy[k];
</span><span style="color: rgb(0, 128, 128); ">54</span> <span style="color: rgb(0, 0, 0); ">                        }
</span><span style="color: rgb(0, 128, 128); ">55</span> <span style="color: rgb(0, 0, 0); ">                        </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(count</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">len) {
</span><span style="color: rgb(0, 128, 128); ">56</span> <span style="color: rgb(0, 0, 0); ">                            ok</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 255); ">true</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">57</span> <span style="color: rgb(0, 0, 0); ">                            printf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%d %d\\n</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,i,j);
</span><span style="color: rgb(0, 128, 128); ">58</span> <span style="color: rgb(0, 0, 0); ">                        }
</span><span style="color: rgb(0, 128, 128); ">59</span> <span style="color: rgb(0, 0, 0); ">                    }
</span><span style="color: rgb(0, 128, 128); ">60</span> <span style="color: rgb(0, 0, 0); ">        }
</span><span style="color: rgb(0, 128, 128); ">61</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 128, 0); ">//</span><span style="color: rgb(0, 128, 0); ">printf("\\n");</span><span style="color: rgb(0, 128, 0); ">
</span><span style="color: rgb(0, 128, 128); ">62</span> <span style="color: rgb(0, 128, 0); "></span><span style="color: rgb(0, 0, 0); ">    }
</span><span style="color: rgb(0, 128, 128); ">63</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">64</span> <span style="color: rgb(0, 0, 0); ">    fclose(stdin);
</span><span style="color: rgb(0, 128, 128); ">65</span> <span style="color: rgb(0, 0, 0); ">    fclose(stdout);
</span><span style="color: rgb(0, 128, 128); ">66</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">return</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">67</span> <span style="color: rgb(0, 0, 0); ">}
</span><span style="color: rgb(0, 128, 128); ">68</span> </span></span></font></div><img src ="http://www.cppblog.com/Naeioi/aggbug/132866.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2010-11-07 16:36 <a href="http://www.cppblog.com/Naeioi/archive/2010/11/07/132866.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>