﻿<?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++博客-comiz</title><link>http://www.cppblog.com/comiz/</link><description /><language>zh-cn</language><lastBuildDate>Fri, 17 Apr 2026 03:21:10 GMT</lastBuildDate><pubDate>Fri, 17 Apr 2026 03:21:10 GMT</pubDate><ttl>60</ttl><item><title>a problem of maze</title><link>http://www.cppblog.com/comiz/archive/2007/11/04/35861.html</link><dc:creator>comiz</dc:creator><author>comiz</author><pubDate>Sun, 04 Nov 2007 11:35:00 GMT</pubDate><guid>http://www.cppblog.com/comiz/archive/2007/11/04/35861.html</guid><wfw:comment>http://www.cppblog.com/comiz/comments/35861.html</wfw:comment><comments>http://www.cppblog.com/comiz/archive/2007/11/04/35861.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/comiz/comments/commentRss/35861.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/comiz/services/trackbacks/35861.html</trackback:ping><description><![CDATA[<p><font face=Verdana>Problem Statement</font></p>
<p><font face=Verdana>People enjoy mazes, but they also get them dirty. Arrows, graffiti, and chewing gum are just a few of the souvenirs people leave on the walls. You, the maze keeper, are assigned to whiten the maze walls. Each face of the wall requires one liter of paint, but you are only required to paint visible faces. You are given a map of the maze, and you must determine the amount of paint needed for the job. </font></p>
<p><font face=Verdana>The maze is described by a vector &lt;string&gt; maze, where each character can be either '#' (a wall) or '.' (an empty space). All '.' characters on the perimeter of the map are considered entrances to the maze. Upon entering the maze, one can only move horizontally and vertically through empty spaces, and areas that are not reachable by these movements are not considered visible. Each '#' represents a square block with four wall faces (each side of the square is a face). A face is visible if it is not directly adjacent to another wall (and is in a reachable area of the maze). For example, two adjacent blocks can have at most six visible faces since two of their faces are directly adjacent to each other. All exterior faces on the perimeter are considered visible. </font></p>
<p><font face=Verdana>For example, the following picture represents a trivial maze with just one (wide) entrance and only four empty reachable spaces:<br><br></font></p>
<p><font face=Verdana>&nbsp;</font><a href="http://fm201.img.xiaonei.com/blog/20071029/20/48/A208115722505HEI.png" target=_blank><font face=Verdana><img alt=TroytownKeeper.png src="http://fm201.img.xiaonei.com/blog/20071029/20/48/A208115722505HEI.png"></font></a></p>
<p><font face=Verdana>To whiten this maze you must paint the faces highlighted in yellow above: 16 for its perimeter, plus 8 interior faces. Note that there are faces that are not visible and thus need not be painted. </font></p>
<p><font face=Verdana>Definition &nbsp;&nbsp;&nbsp;&nbsp; </font></p>
<p><font face=Verdana>Class: TroytownKeeper </font></p>
<p><font face=Verdana>Method: limeLiters Parameters: vector &lt;string&gt; </font></p>
<p><font face=Verdana>Returns: int </font></p>
<p><font face=Verdana>Method signature: int limeLiters(vector &lt;string&gt; maze) </font></p>
<p><font face=Verdana>(be sure your method is public) &nbsp;&nbsp;&nbsp;&nbsp;</font></p>
<p><font face=Verdana>Constraints </font></p>
<p><font face=Verdana>- maze will contain between 1 and 50 elements, inclusive. </font></p>
<p><font face=Verdana>- Each element of maze will contain between 1 and 50 characters, inclusive. </font></p>
<p><font face=Verdana>- All elements of maze will have the same number of characters. </font></p>
<p><font face=Verdana>- All characters in maze will be either '.' or '#' . Examples 0) &nbsp;</font></p>
<p><font face=Verdana>&nbsp;</font></p>
<p><font face=Verdana>&nbsp;&nbsp;&nbsp; </font></p>
<pre><font face=Verdana>{"##..#",</font></pre>
<pre><font face=Verdana>"#.#.#",</font></pre>
<pre><font face=Verdana>"#.#.#",</font></pre>
<pre><font face=Verdana>"#####"}</font></pre>
<pre><font face=Verdana>Returns: 24</font></pre>
<img src ="http://www.cppblog.com/comiz/aggbug/35861.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/comiz/" target="_blank">comiz</a> 2007-11-04 19:35 <a href="http://www.cppblog.com/comiz/archive/2007/11/04/35861.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一道基础题</title><link>http://www.cppblog.com/comiz/archive/2007/10/24/35073.html</link><dc:creator>comiz</dc:creator><author>comiz</author><pubDate>Wed, 24 Oct 2007 10:22:00 GMT</pubDate><guid>http://www.cppblog.com/comiz/archive/2007/10/24/35073.html</guid><wfw:comment>http://www.cppblog.com/comiz/comments/35073.html</wfw:comment><comments>http://www.cppblog.com/comiz/archive/2007/10/24/35073.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/comiz/comments/commentRss/35073.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/comiz/services/trackbacks/35073.html</trackback:ping><description><![CDATA[<p><strong></strong><font size=2><strong><span>将<span>1</span>，<span>2</span>，&#8230;，<span>9</span>共<span>9</span>个数分成三组，分别组成三个三位数，且使这三个三位数构成</span></strong></font></p>
<p><font size=2><font size=2><strong><span><span>&nbsp;&nbsp; </span>1</span></strong></font><strong><span><font size=2>：<span>2</span>：<span>3</span>的比例，试求出所有满足条件的三个三位数。</font></span></strong></font></p>
<font size=2><strong><span><span>&nbsp;&nbsp; </span></span></strong></font><strong><span><font size=2>例如：三个三位数192，384，576满足以上条件。</font><span><span><font size=2><span> </span><br><span>题目比较基础,自己用的回朔法,万里高楼平地起，慢慢来吧...</span><br><span>/* Note:Your choice is C IDE */</span><br><span>#define null 0</span><br><span>#include "stdio.h"</span><br><span>void inject(int N,int *nNum)</span><br><span>{</span><br><span>&nbsp;&nbsp;&nbsp; int sum[3],i,j,k;</span><br><span>&nbsp;&nbsp;&nbsp; if(N==0)</span><br><span>&nbsp;&nbsp;&nbsp; {</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sum[0]=*nNum*100+*(nNum+1)*10+*(nNum+2);</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sum[1]=*(nNum+3)*100+*(nNum+4)*10+*(nNum+5);</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sum[2]=*(nNum+6)*100+*(nNum+7)*10+*(nNum+8);</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(((sum[0]&lt;&lt;1)==sum[1])&amp;&amp;((3*sum[0])==sum[2]))</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; printf("we have one of them:");&nbsp;&nbsp;&nbsp; </span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; printf("%d,%d,%d\n",sum[0],sum[1],sum[2]);</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br><span>&nbsp;&nbsp;&nbsp; }</span><br><span>&nbsp;&nbsp;&nbsp; else</span><br><span>&nbsp;&nbsp;&nbsp; {</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for(j=0;j&lt;9;j++)</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(*(nNum+j)==null)</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *(nNum+j)=N;</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; inject(N-1,nNum);</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *(nNum+j)=null;</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br><span>&nbsp;&nbsp;&nbsp; }</span><br><span>}</span><br><span>main()</span><br><span>{</span><br><span>&nbsp;&nbsp;&nbsp; int k;</span><br><span>&nbsp;&nbsp;&nbsp; int Num[9];</span><br><span>&nbsp;&nbsp;&nbsp; for(k=0;k&lt;9;k++)</span><br><span>&nbsp;&nbsp;&nbsp; {</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Num[k]=null;&nbsp;&nbsp;&nbsp; </span><br><span>&nbsp;&nbsp;&nbsp; }</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; inject(9,Num);</span><br><span>}</span></font><br></span></span></span></strong>
<img src ="http://www.cppblog.com/comiz/aggbug/35073.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/comiz/" target="_blank">comiz</a> 2007-10-24 18:22 <a href="http://www.cppblog.com/comiz/archive/2007/10/24/35073.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>