﻿<?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++博客-Vontroy-随笔分类-字符串</title><link>http://www.cppblog.com/vontroy/category/15061.html</link><description /><language>zh-cn</language><lastBuildDate>Fri, 02 Sep 2016 13:42:57 GMT</lastBuildDate><pubDate>Fri, 02 Sep 2016 13:42:57 GMT</pubDate><ttl>60</ttl><item><title>字典树(Trie树)</title><link>http://www.cppblog.com/vontroy/archive/2016/08/31/214243.html</link><dc:creator>Vontroy</dc:creator><author>Vontroy</author><pubDate>Wed, 31 Aug 2016 01:35:00 GMT</pubDate><guid>http://www.cppblog.com/vontroy/archive/2016/08/31/214243.html</guid><wfw:comment>http://www.cppblog.com/vontroy/comments/214243.html</wfw:comment><comments>http://www.cppblog.com/vontroy/archive/2016/08/31/214243.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/vontroy/comments/commentRss/214243.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/vontroy/services/trackbacks/214243.html</trackback:ping><description><![CDATA[<p style="margin: 0px; padding: 0px; color: #555555; font-family: &quot;microsoft yahei&quot;; font-size: 15px; line-height: 35px; background-color: #ffffff;"><img src="http://img.blog.csdn.net/20151128210114865" alt="" style="border: none; max-width: 602px; height: auto; font-family: Courier; font-size: 12pt;" /><br /></p><p style="margin: 0px; padding: 0px; color: #555555; font-family: &quot;microsoft yahei&quot;; font-size: 15px; line-height: 35px; background-color: #ffffff;"><span style="font-family: Courier; font-size: 12pt;">如图，每条路径上保存一个字母，从根节点开始进行dfs，每遍历到一个标记节点（图中的红点），从根节点到当前节点路径上所有字母连起来即为一个单词</span></p><p style="margin: 0px; padding: 0px; color: #555555; font-family: &quot;microsoft yahei&quot;; font-size: 15px; line-height: 35px; background-color: #ffffff;"><span style="font-family: Courier; font-size: 12pt;">上图中存储了 abc, abcd, b, bcd, efg, hij.</span></p><p style="margin: 0px; padding: 0px; color: #555555; font-family: &quot;microsoft yahei&quot;; font-size: 15px; line-height: 35px; background-color: #ffffff;"><span style="font-family: Courier; font-size: 12pt;">对于Trie树主要有三种操作：</span></p><p style="margin: 0px; padding: 0px; color: #555555; font-family: &quot;microsoft yahei&quot;; font-size: 15px; line-height: 35px; background-color: #ffffff;"></p><ol style="color: #555555; font-family: &quot;microsoft yahei&quot;; font-size: 15px; line-height: 35px; background-color: #ffffff;"><li><span style="font-family: Courier; font-size: 12pt;">新建一个结点</span></li><li><span style="font-family: Courier; font-size: 12pt;">插入一个单词</span></li><li><span style="font-family: Courier; font-size: 12pt;">在trie树中查找单词</span></li></ol><div style="color: #555555; font-family: &quot;microsoft yahei&quot;; font-size: 15px; line-height: 35px; background-color: #ffffff;"><span style="font-family: Courier; font-size: 12pt;">trie树中每次插入一个结点的时间复杂度是 O( strlen( str ) )</span></div><div style="color: #555555; font-family: &quot;microsoft yahei&quot;; font-size: 15px; line-height: 35px; background-color: #ffffff;"><span style="font-family: Courier; font-size: 12pt;">建立trie树的时间复杂度为 O( &#8721;strlen( str[i] ) )</span></div><div style="color: #555555; font-family: &quot;microsoft yahei&quot;; font-size: 15px; line-height: 35px; background-color: #ffffff;"><span style="font-family: Courier; font-size: 12pt;">对于每个单词，查询的时间复杂度为 O( strlen( str ) )</span><br /><br /><h2><span style="font-family: Courier; font-size: 12pt;">Templates:</span></h2><h3><span style="font-family: Courier; font-size: 12pt;">Struct:</span></h3><div style="font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all; background-color: #eeeeee;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">struct</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;node&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">{&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">int</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;flag;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000; font-family: Courier; font-size: 12pt;">//</span><span style="color: #008000; font-family: Courier; font-size: 12pt;">The&nbsp;end&nbsp;of&nbsp;a&nbsp;word&nbsp;&nbsp;</span><span style="color: #008000; "><br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;node</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">*</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;next[</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">26</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">];&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">}; &nbsp;</span></div><br /><h3><span style="font-family: Courier; font-size: 12pt;">新建结点：</span></h3><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: #000000; font-family: Courier; font-size: 12pt;">node</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">*</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;newnode()&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">{&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;node</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">*</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;p&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">new</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;node;&nbsp;&nbsp;<br />&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">-&gt;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">flag&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">0</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">;&nbsp;&nbsp;<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">for</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">(&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">int</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;i&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">0</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">;&nbsp;i&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&lt;</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">26</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">;&nbsp;i</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">++</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;)&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">-&gt;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">next[i]&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;NULL;&nbsp;&nbsp;<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">return</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;p;&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">} &nbsp;</span></div><h3><span style="font-family: Courier; font-size: 12pt;">插入单词：</span></h3><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: #0000ff; font-family: Courier; font-size: 12pt;">void</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;trie_insert(&nbsp;node</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">*</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;root,&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">char</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">*</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;s&nbsp;)&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">{&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;node</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">*</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;p&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;root;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">int</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;len&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;strlen(&nbsp;s&nbsp;);&nbsp;&nbsp;<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">int</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;tmp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">for</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">(&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">int</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;i&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">0</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">;&nbsp;i&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&lt;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;len;&nbsp;i</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">++</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;)&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tmp&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;s[i]&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">-</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">'</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">a</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">'</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">if</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">(&nbsp;p</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">-&gt;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">next[tmp]&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">==</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;NULL&nbsp;)&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">-&gt;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">next[tmp]&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;newnode();&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;p</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">-&gt;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">next[tmp];&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">-&gt;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">flag&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">1</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">;&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">} &nbsp;</span></div><h3><span style="font-family: Courier; font-size: 12pt;">查询：</span></h3><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: #0000ff; font-family: Courier; font-size: 12pt;">int</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;trie_search(&nbsp;node</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">*</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;root,&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">char</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">*</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;s&nbsp;)&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">{&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;node</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">*</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;p&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;root;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">int</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;len&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;strlen(&nbsp;s&nbsp;);&nbsp;&nbsp;<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">int</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;tmp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">for</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">(&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">int</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;i&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">0</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">;&nbsp;i&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&lt;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;len;&nbsp;i</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">++</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;)&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tmp&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;s[i]&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">-</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">'</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">a</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">'</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">if</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">(&nbsp;p</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">-&gt;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">next[tmp]&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">==</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;NULL&nbsp;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000; font-family: Courier; font-size: 12pt;">//</span><span style="color: #008000; font-family: Courier; font-size: 12pt;">not&nbsp;matched&nbsp;&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; font-family: Courier; font-size: 12pt;">return</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">0</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">;&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">=</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;p</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">-&gt;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">next[tmp];&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">if</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">(&nbsp;p</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">-&gt;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">flag&nbsp;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000; font-family: Courier; font-size: 12pt;">//</span><span style="color: #008000; font-family: Courier; font-size: 12pt;">match&nbsp;&amp;&amp;&nbsp;it&nbsp;is&nbsp;a&nbsp;word&nbsp;which&nbsp;has&nbsp;been&nbsp;stored&nbsp;&nbsp;<br /></span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">&nbsp; &nbsp; return</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">1</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-family: Courier; font-size: 12pt;">return</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">0</span><span style="color: #000000; font-family: Courier; font-size: 12pt;">;&nbsp;&nbsp;<br /></span><span style="color: #000000; font-family: Courier; font-size: 12pt;">} &nbsp;</span></div></div><img src ="http://www.cppblog.com/vontroy/aggbug/214243.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/vontroy/" target="_blank">Vontroy</a> 2016-08-31 09:35 <a href="http://www.cppblog.com/vontroy/archive/2016/08/31/214243.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 2734 Quicksum 简单字符串处理</title><link>http://www.cppblog.com/vontroy/archive/2010/10/03/128420.html</link><dc:creator>Vontroy</dc:creator><author>Vontroy</author><pubDate>Sun, 03 Oct 2010 02:03:00 GMT</pubDate><guid>http://www.cppblog.com/vontroy/archive/2010/10/03/128420.html</guid><wfw:comment>http://www.cppblog.com/vontroy/comments/128420.html</wfw:comment><comments>http://www.cppblog.com/vontroy/archive/2010/10/03/128420.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/vontroy/comments/commentRss/128420.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/vontroy/services/trackbacks/128420.html</trackback:ping><description><![CDATA[<span style="widows: 2; text-transform: none; text-indent: 0px; border-collapse: separate; font: medium Simsun; white-space: normal; orphans: 2; letter-spacing: normal; color: #000000; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="Apple-style-span"><span style="font-family: 'Times New Roman'" class="Apple-style-span">
<h1 style="text-align: center; color: #1a5cc8" align="center">Quicksum</h1>
<p align="center"><font size="+0"><strong><span style="font-family: Arial; color: green; font-size: 12px; font-weight: bold">Time Limit: 2000/1000 MS (Java/Others)&nbsp;&nbsp;&nbsp;&nbsp;Memory Limit: 32768/32768 K (Java/Others)<br />Total Submission(s): 492&nbsp;&nbsp;&nbsp;&nbsp;Accepted Submission(s): 408<br /></span></strong></font><br /></p>
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-title.png); padding-bottom: 0px; background-color: transparent; padding-left: 14px; padding-right: 14px; background-repeat: no-repeat; font-family: Arial; background-position: 0% 100%; height: 38px; color: #7ca9ed; font-size: 18px; font-weight: bold; padding-top: 0px; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_title" align="left">Problem Description</div>
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-content.png); text-align: left; padding-bottom: 0px; margin: 0px; padding-left: 20px; padding-right: 20px; background-repeat: repeat-y; font-family: 'Times New Roman'; height: auto; font-size: 14px; padding-top: 0px; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_content">A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors, validating document contents, and in many other situations where it is necessary to detect undesirable changes in data.<br /><br />For this problem, you will implement a checksum algorithm called Quicksum. A Quicksum packet allows only uppercase letters and spaces. It always begins and ends with an uppercase letter. Otherwise, spaces and letters can occur in any combination, including consecutive spaces.<br /><br />A Quicksum is the sum of the products of each character's position in the packet times the character's value. A space has a value of zero, while letters have a value equal to their position in the alphabet. So, A=1, B=2, etc., through Z=26. Here are example Quicksum calculations for the packets "ACM" and "MID CENTRAL":<br /><br />ACM: 1*1 + 2*3 + 3*13 = 46MID CENTRAL: 1*13 + 2*9 + 3*4 + 4*0 + 5*3 + 6*5 + 7*14 + 8*20 + 9*18 + 10*1 + 11*12 = 650</div>
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-bottom.png); margin: 0px; background-repeat: no-repeat; background-position: 0% 0%; height: auto; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_bottom">&nbsp;</div>
<br />
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-title.png); padding-bottom: 0px; background-color: transparent; padding-left: 14px; padding-right: 14px; background-repeat: no-repeat; font-family: Arial; background-position: 0% 100%; height: 38px; color: #7ca9ed; font-size: 18px; font-weight: bold; padding-top: 0px; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_title" align="left">Input</div>
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-content.png); text-align: left; padding-bottom: 0px; margin: 0px; padding-left: 20px; padding-right: 20px; background-repeat: repeat-y; font-family: 'Times New Roman'; height: auto; font-size: 14px; padding-top: 0px; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_content">The input consists of one or more packets followed by a line containing only # that signals the end of the input. Each packet is on a line by itself, does not begin or end with a space, and contains from 1 to 255 characters.</div>
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-bottom.png); margin: 0px; background-repeat: no-repeat; background-position: 0% 0%; height: auto; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_bottom">&nbsp;</div>
<br />
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-title.png); padding-bottom: 0px; background-color: transparent; padding-left: 14px; padding-right: 14px; background-repeat: no-repeat; font-family: Arial; background-position: 0% 100%; height: 38px; color: #7ca9ed; font-size: 18px; font-weight: bold; padding-top: 0px; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_title" align="left">Output</div>
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-content.png); text-align: left; padding-bottom: 0px; margin: 0px; padding-left: 20px; padding-right: 20px; background-repeat: repeat-y; font-family: 'Times New Roman'; height: auto; font-size: 14px; padding-top: 0px; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_content">For each packet, output its Quicksum on a separate line in the output.<br /></div>
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-bottom.png); margin: 0px; background-repeat: no-repeat; background-position: 0% 0%; height: auto; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_bottom">&nbsp;</div>
<br />
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-title.png); padding-bottom: 0px; background-color: transparent; padding-left: 14px; padding-right: 14px; background-repeat: no-repeat; font-family: Arial; background-position: 0% 100%; height: 38px; color: #7ca9ed; font-size: 18px; font-weight: bold; padding-top: 0px; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_title" align="left">Sample Input</div>
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-content.png); text-align: left; padding-bottom: 0px; margin: 0px; padding-left: 20px; padding-right: 20px; background-repeat: repeat-y; font-family: 'Times New Roman'; height: auto; font-size: 14px; padding-top: 0px; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_content">
<pre style="margin: 0px; font-size: 14px"><div style="font-family: 'Courier New', Courier, monospace">ACM
MID CENTRAL
REGIONAL PROGRAMMING CONTEST
ACN
A C M
ABC
BBC
#</div>
</pre>
</div>
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-bottom.png); margin: 0px; background-repeat: no-repeat; background-position: 0% 0%; height: auto; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_bottom">&nbsp;</div>
<br />
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-title.png); padding-bottom: 0px; background-color: transparent; padding-left: 14px; padding-right: 14px; background-repeat: no-repeat; font-family: Arial; background-position: 0% 100%; height: 38px; color: #7ca9ed; font-size: 18px; font-weight: bold; padding-top: 0px; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_title" align="left">Sample Output</div>
<div style="background-image: url(http://acm.hdu.edu.cn/images/panel-content.png); text-align: left; padding-bottom: 0px; margin: 0px; padding-left: 20px; padding-right: 20px; background-repeat: repeat-y; font-family: 'Times New Roman'; height: auto; font-size: 14px; padding-top: 0px; -webkit-background-clip: initial; -webkit-background-origin: initial" class="panel_content">
<pre style="margin: 0px; font-size: 14px"><div style="font-family: 'Courier New', Courier, monospace">46
650
4690
49
75
14
15</div>
</pre>
</div>
<br /><br />
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><span style="color: #000000">#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">iostream</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#include&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 /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">cstring</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_69_446_Open_Image" onclick="this.style.display='none'; Codehighlighter1_69_446_Open_Text.style.display='none'; Codehighlighter1_69_446_Closed_Image.style.display='inline'; Codehighlighter1_69_446_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_69_446_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_69_446_Closed_Text.style.display='none'; Codehighlighter1_69_446_Open_Image.style.display='inline'; Codehighlighter1_69_446_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_69_446_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_69_446_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;str[</span><span style="color: #000000">260</span><span style="color: #000000">];<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;ans&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(&nbsp;gets(str)&nbsp;</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">&nbsp;str[</span><span style="color: #000000">0</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">!=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">#</span><span style="color: #000000">'</span><span style="color: #000000">&nbsp;)<br /><img id="Codehighlighter1_151_430_Open_Image" onclick="this.style.display='none'; Codehighlighter1_151_430_Open_Text.style.display='none'; Codehighlighter1_151_430_Closed_Image.style.display='inline'; Codehighlighter1_151_430_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_151_430_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_151_430_Closed_Text.style.display='none'; Codehighlighter1_151_430_Open_Image.style.display='inline'; Codehighlighter1_151_430_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_151_430_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_151_430_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;len&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;strlen(str);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;len;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">&nbsp;)<br /><img id="Codehighlighter1_248_385_Open_Image" onclick="this.style.display='none'; Codehighlighter1_248_385_Open_Text.style.display='none'; Codehighlighter1_248_385_Closed_Image.style.display='inline'; Codehighlighter1_248_385_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_248_385_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_248_385_Closed_Text.style.display='none'; Codehighlighter1_248_385_Open_Image.style.display='inline'; Codehighlighter1_248_385_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_248_385_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_248_385_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;str[i]&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">&nbsp;)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">continue</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans&nbsp;</span><span style="color: #000000">+=</span><span style="color: #000000">&nbsp;(&nbsp;str[i]&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">64</span><span style="color: #000000">&nbsp;)&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;(&nbsp;i&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">&nbsp;);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;ans&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;std::endl;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span></div>
</span></span><img src ="http://www.cppblog.com/vontroy/aggbug/128420.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/vontroy/" target="_blank">Vontroy</a> 2010-10-03 10:03 <a href="http://www.cppblog.com/vontroy/archive/2010/10/03/128420.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>POJ 1007 DNA Sorting 字符串处理|稳定排序</title><link>http://www.cppblog.com/vontroy/archive/2010/10/02/128354.html</link><dc:creator>Vontroy</dc:creator><author>Vontroy</author><pubDate>Sat, 02 Oct 2010 13:23:00 GMT</pubDate><guid>http://www.cppblog.com/vontroy/archive/2010/10/02/128354.html</guid><wfw:comment>http://www.cppblog.com/vontroy/comments/128354.html</wfw:comment><comments>http://www.cppblog.com/vontroy/archive/2010/10/02/128354.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/vontroy/comments/commentRss/128354.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/vontroy/services/trackbacks/128354.html</trackback:ping><description><![CDATA[<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><img id="Codehighlighter1_0_48_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_48_Open_Text.style.display='none'; Codehighlighter1_0_48_Closed_Image.style.display='inline'; Codehighlighter1_0_48_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_0_48_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_0_48_Closed_Text.style.display='none'; Codehighlighter1_0_48_Open_Image.style.display='inline'; Codehighlighter1_0_48_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_0_48_Closed_Text">/**/</span><span id="Codehighlighter1_0_48_Open_Text"><span style="color: #008000">/*</span><span style="color: #008000">****************<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />字符串处理<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />稳定排序<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />*****************</span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">iostream</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">algorithm</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #0000ff">string</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;std;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">struct</span><span style="color: #000000">&nbsp;DNA<br /><img id="Codehighlighter1_144_188_Open_Image" onclick="this.style.display='none'; Codehighlighter1_144_188_Open_Text.style.display='none'; Codehighlighter1_144_188_Closed_Image.style.display='inline'; Codehighlighter1_144_188_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_144_188_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_144_188_Closed_Text.style.display='none'; Codehighlighter1_144_188_Open_Image.style.display='inline'; Codehighlighter1_144_188_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_144_188_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_144_188_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;pos;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;cnt;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">string</span><span style="color: #000000">&nbsp;str;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">bool</span><span style="color: #000000">&nbsp;cmp(</span><span style="color: #0000ff">const</span><span style="color: #000000">&nbsp;DNA&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">a,&nbsp;</span><span style="color: #0000ff">const</span><span style="color: #000000">&nbsp;DNA&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">b)<br /><img id="Codehighlighter1_229_348_Open_Image" onclick="this.style.display='none'; Codehighlighter1_229_348_Open_Text.style.display='none'; Codehighlighter1_229_348_Closed_Image.style.display='inline'; Codehighlighter1_229_348_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_229_348_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_229_348_Closed_Text.style.display='none'; Codehighlighter1_229_348_Open_Image.style.display='inline'; Codehighlighter1_229_348_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_229_348_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_229_348_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(a.cnt&nbsp;</span><span style="color: #000000">!=</span><span style="color: #000000">&nbsp;b.cnt)<br /><img id="Codehighlighter1_259_295_Open_Image" onclick="this.style.display='none'; Codehighlighter1_259_295_Open_Text.style.display='none'; Codehighlighter1_259_295_Closed_Image.style.display='inline'; Codehighlighter1_259_295_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_259_295_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_259_295_Closed_Text.style.display='none'; Codehighlighter1_259_295_Open_Image.style.display='inline'; Codehighlighter1_259_295_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_259_295_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_259_295_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;a.cnt&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;b.cnt;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000"><br /><img id="Codehighlighter1_310_346_Open_Image" onclick="this.style.display='none'; Codehighlighter1_310_346_Open_Text.style.display='none'; Codehighlighter1_310_346_Closed_Image.style.display='inline'; Codehighlighter1_310_346_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_310_346_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_310_346_Closed_Text.style.display='none'; Codehighlighter1_310_346_Open_Image.style.display='inline'; Codehighlighter1_310_346_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_310_346_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_310_346_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;a.pos&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;b.pos;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_362_870_Open_Image" onclick="this.style.display='none'; Codehighlighter1_362_870_Open_Text.style.display='none'; Codehighlighter1_362_870_Closed_Image.style.display='inline'; Codehighlighter1_362_870_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_362_870_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_362_870_Closed_Text.style.display='none'; Codehighlighter1_362_870_Open_Image.style.display='inline'; Codehighlighter1_362_870_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_362_870_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_362_870_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;n,&nbsp;m,&nbsp;count;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;DNA&nbsp;ans[</span><span style="color: #000000">110</span><span style="color: #000000">];<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">string</span><span style="color: #000000">&nbsp;str;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;cin&nbsp;</span><span style="color: #000000">&gt;&gt;</span><span style="color: #000000">&nbsp;n&nbsp;</span><span style="color: #000000">&gt;&gt;</span><span style="color: #000000">&nbsp;m;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;m;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img id="Codehighlighter1_475_754_Open_Image" onclick="this.style.display='none'; Codehighlighter1_475_754_Open_Text.style.display='none'; Codehighlighter1_475_754_Closed_Image.style.display='inline'; Codehighlighter1_475_754_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_475_754_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_475_754_Closed_Text.style.display='none'; Codehighlighter1_475_754_Open_Image.style.display='inline'; Codehighlighter1_475_754_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_475_754_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_475_754_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cin&nbsp;</span><span style="color: #000000">&gt;&gt;</span><span style="color: #000000">&nbsp;str;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;j&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;&nbsp;j&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;n&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;&nbsp;j</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;k&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;j&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;&nbsp;k&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;n;&nbsp;k</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(str[j]&nbsp;</span><span style="color: #000000">&gt;</span><span style="color: #000000">&nbsp;str[k])&nbsp;count</span><span style="color: #000000">++</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans[i].str&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;str;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans[i].cnt&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;count;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans[i].pos&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;i;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;sort(ans,&nbsp;ans&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;m,&nbsp;cmp);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;m;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;ans[i].str&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span></div><img src ="http://www.cppblog.com/vontroy/aggbug/128354.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/vontroy/" target="_blank">Vontroy</a> 2010-10-02 21:23 <a href="http://www.cppblog.com/vontroy/archive/2010/10/02/128354.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>POJ 1002 487-3279 字符串处理</title><link>http://www.cppblog.com/vontroy/archive/2010/10/02/128340.html</link><dc:creator>Vontroy</dc:creator><author>Vontroy</author><pubDate>Sat, 02 Oct 2010 11:21:00 GMT</pubDate><guid>http://www.cppblog.com/vontroy/archive/2010/10/02/128340.html</guid><wfw:comment>http://www.cppblog.com/vontroy/comments/128340.html</wfw:comment><comments>http://www.cppblog.com/vontroy/archive/2010/10/02/128340.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/vontroy/comments/commentRss/128340.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/vontroy/services/trackbacks/128340.html</trackback:ping><description><![CDATA[<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><span style="color: #000000">#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">iostream</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #0000ff">string</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">algorithm</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#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 /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">const</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;maxn&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">20000</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">const</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;MAXN&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">100000</span><span style="color: #000000">+</span><span style="color: #000000">10</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;std&nbsp;::&nbsp;</span><span style="color: #0000ff">string</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;std&nbsp;::&nbsp;cout;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;std&nbsp;::&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_202_2379_Open_Image" onclick="this.style.display='none'; Codehighlighter1_202_2379_Open_Text.style.display='none'; Codehighlighter1_202_2379_Closed_Image.style.display='inline'; Codehighlighter1_202_2379_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_202_2379_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_202_2379_Closed_Text.style.display='none'; Codehighlighter1_202_2379_Open_Image.style.display='inline'; Codehighlighter1_202_2379_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_202_2379_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_202_2379_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">string</span><span style="color: #000000">&nbsp;ans[MAXN];<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;tel[maxn];<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;store[maxn];<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;n;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">bool</span><span style="color: #000000">&nbsp;ok;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(</span><span style="color: #000000">~</span><span style="color: #000000">&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">n))<br /><img id="Codehighlighter1_323_2363_Open_Image" onclick="this.style.display='none'; Codehighlighter1_323_2363_Open_Text.style.display='none'; Codehighlighter1_323_2363_Closed_Image.style.display='inline'; Codehighlighter1_323_2363_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_323_2363_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_323_2363_Closed_Text.style.display='none'; Codehighlighter1_323_2363_Open_Image.style.display='inline'; Codehighlighter1_323_2363_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_323_2363_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_323_2363_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ok&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">false</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;count&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(n</span><span style="color: #000000">--</span><span style="color: #000000">)<br /><img id="Codehighlighter1_395_1730_Open_Image" onclick="this.style.display='none'; Codehighlighter1_395_1730_Open_Text.style.display='none'; Codehighlighter1_395_1730_Closed_Image.style.display='inline'; Codehighlighter1_395_1730_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_395_1730_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_395_1730_Closed_Text.style.display='none'; Codehighlighter1_395_1730_Open_Image.style.display='inline'; Codehighlighter1_395_1730_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_395_1730_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_395_1730_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%s</span><span style="color: #000000">"</span><span style="color: #000000">,tel);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;j;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">,j&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;&nbsp;tel[i]&nbsp;</span><span style="color: #000000">!=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">\0</span><span style="color: #000000">'</span><span style="color: #000000">;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img id="Codehighlighter1_512_1686_Open_Image" onclick="this.style.display='none'; Codehighlighter1_512_1686_Open_Text.style.display='none'; Codehighlighter1_512_1686_Closed_Image.style.display='inline'; Codehighlighter1_512_1686_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_512_1686_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_512_1686_Closed_Text.style.display='none'; Codehighlighter1_512_1686_Open_Image.style.display='inline'; Codehighlighter1_512_1686_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_512_1686_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_512_1686_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(tel[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">&gt;=</span><span style="color: #000000">0</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">tel[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">&lt;=</span><span style="color: #000000">9</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;store[j</span><span style="color: #000000">++</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;tel[i];<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(tel[i]&nbsp;</span><span style="color: #000000">!=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">-</span><span style="color: #000000">'</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">&nbsp;j&nbsp;</span><span style="color: #000000">!=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">3</span><span style="color: #000000">&nbsp;)<br /><img id="Codehighlighter1_672_1628_Open_Image" onclick="this.style.display='none'; Codehighlighter1_672_1628_Open_Text.style.display='none'; Codehighlighter1_672_1628_Closed_Image.style.display='inline'; Codehighlighter1_672_1628_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_672_1628_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_672_1628_Closed_Text.style.display='none'; Codehighlighter1_672_1628_Open_Image.style.display='inline'; Codehighlighter1_672_1628_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_672_1628_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_672_1628_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">ans[count]+='2';</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" /></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;</span><span style="color: #0000ff">if</span><span style="color: #000000">(tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">A</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">B</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">C</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;store[j</span><span style="color: #000000">++</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">2</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">D</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">E</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">F</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;store[j</span><span style="color: #000000">++</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">3</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">G</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">H</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">I</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;store[j</span><span style="color: #000000">++</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">4</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">J</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">K</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">L</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;store[j</span><span style="color: #000000">++</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">5</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">M</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">N</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">O</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;store[j</span><span style="color: #000000">++</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">6</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">P</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">R</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">S</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;store[j</span><span style="color: #000000">++</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">7</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">T</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">U</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">V</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;store[j</span><span style="color: #000000">++</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">8</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">W</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">X</span><span style="color: #000000">'</span><span style="color: #000000">||</span><span style="color: #000000">tel[i]</span><span style="color: #000000">==</span><span style="color: #000000">'</span><span style="color: #000000">Y</span><span style="color: #000000">'</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;store[j</span><span style="color: #000000">++</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">9</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;j</span><span style="color: #000000">==</span><span style="color: #000000">3</span><span style="color: #000000">&nbsp;)&nbsp;&nbsp;store[j</span><span style="color: #000000">++</span><span style="color: #000000">]</span><span style="color: #000000">=</span><span style="color: #000000">'</span><span style="color: #000000">-</span><span style="color: #000000">'</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans[count</span><span style="color: #000000">++</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;store;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std&nbsp;::&nbsp;sort(ans,ans</span><span style="color: #000000">+</span><span style="color: #000000">count);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;ans_count;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;count;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img id="Codehighlighter1_1838_2217_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1838_2217_Open_Text.style.display='none'; Codehighlighter1_1838_2217_Closed_Image.style.display='inline'; Codehighlighter1_1838_2217_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1838_2217_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1838_2217_Closed_Text.style.display='none'; Codehighlighter1_1838_2217_Open_Image.style.display='inline'; Codehighlighter1_1838_2217_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1838_2217_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1838_2217_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans_count&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&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&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;&nbsp;j&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;count;&nbsp;j</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img id="Codehighlighter1_1929_2022_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1929_2022_Open_Text.style.display='none'; Codehighlighter1_1929_2022_Closed_Image.style.display='inline'; Codehighlighter1_1929_2022_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1929_2022_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1929_2022_Closed_Text.style.display='none'; Codehighlighter1_1929_2022_Open_Image.style.display='inline'; Codehighlighter1_1929_2022_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1929_2022_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1929_2022_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(ans[j]</span><span style="color: #000000">==</span><span style="color: #000000">ans[i])&nbsp;ans_count</span><span style="color: #000000">++</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">break</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(ans_count&nbsp;</span><span style="color: #000000">&gt;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">)<br /><img id="Codehighlighter1_2068_2207_Open_Image" onclick="this.style.display='none'; Codehighlighter1_2068_2207_Open_Text.style.display='none'; Codehighlighter1_2068_2207_Closed_Image.style.display='inline'; Codehighlighter1_2068_2207_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_2068_2207_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_2068_2207_Closed_Text.style.display='none'; Codehighlighter1_2068_2207_Open_Image.style.display='inline'; Codehighlighter1_2068_2207_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_2068_2207_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_2068_2207_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ok&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">true</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;ans[i]&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;ans_count&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i</span><span style="color: #000000">+=</span><span style="color: #000000">(ans_count</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(</span><span style="color: #000000">!</span><span style="color: #000000">ok)&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">No&nbsp;duplicates.</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">for(int&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;count;&nbsp;i++)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">std&nbsp;::&nbsp;cout&nbsp;&lt;&lt;&nbsp;ans[i]&nbsp;&lt;&lt;&nbsp;std&nbsp;::&nbsp;endl;</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span></div><img src ="http://www.cppblog.com/vontroy/aggbug/128340.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/vontroy/" target="_blank">Vontroy</a> 2010-10-02 19:21 <a href="http://www.cppblog.com/vontroy/archive/2010/10/02/128340.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>