﻿<?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++博客-DraculaW</title><link>http://www.cppblog.com/DraculaW/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 14 Apr 2026 23:08:37 GMT</lastBuildDate><pubDate>Tue, 14 Apr 2026 23:08:37 GMT</pubDate><ttl>60</ttl><item><title>尝试写一个智能指针把</title><link>http://www.cppblog.com/DraculaW/archive/2008/11/28/68091.html</link><dc:creator>DraculaW</dc:creator><author>DraculaW</author><pubDate>Fri, 28 Nov 2008 09:39:00 GMT</pubDate><guid>http://www.cppblog.com/DraculaW/archive/2008/11/28/68091.html</guid><wfw:comment>http://www.cppblog.com/DraculaW/comments/68091.html</wfw:comment><comments>http://www.cppblog.com/DraculaW/archive/2008/11/28/68091.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DraculaW/comments/commentRss/68091.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DraculaW/services/trackbacks/68091.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 我尝试写的一个智能指针<br>希望大家能帮我提一些意见 谢谢<br><br>上面是测试码<br>下面是代码&nbsp;&nbsp;<a href='http://www.cppblog.com/DraculaW/archive/2008/11/28/68091.html'>阅读全文</a><img src ="http://www.cppblog.com/DraculaW/aggbug/68091.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DraculaW/" target="_blank">DraculaW</a> 2008-11-28 17:39 <a href="http://www.cppblog.com/DraculaW/archive/2008/11/28/68091.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>跨越了一座山的一半 了解了rb树插入的平衡问题</title><link>http://www.cppblog.com/DraculaW/archive/2007/11/22/37172.html</link><dc:creator>DraculaW</dc:creator><author>DraculaW</author><pubDate>Thu, 22 Nov 2007 12:47:00 GMT</pubDate><guid>http://www.cppblog.com/DraculaW/archive/2007/11/22/37172.html</guid><wfw:comment>http://www.cppblog.com/DraculaW/comments/37172.html</wfw:comment><comments>http://www.cppblog.com/DraculaW/archive/2007/11/22/37172.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DraculaW/comments/commentRss/37172.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DraculaW/services/trackbacks/37172.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 红黑树的插入算法的描述 不知道清楚么 希望大家指正&nbsp;&nbsp;<a href='http://www.cppblog.com/DraculaW/archive/2007/11/22/37172.html'>阅读全文</a><img src ="http://www.cppblog.com/DraculaW/aggbug/37172.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DraculaW/" target="_blank">DraculaW</a> 2007-11-22 20:47 <a href="http://www.cppblog.com/DraculaW/archive/2007/11/22/37172.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Best Fit与 First Fit</title><link>http://www.cppblog.com/DraculaW/archive/2007/11/21/37108.html</link><dc:creator>DraculaW</dc:creator><author>DraculaW</author><pubDate>Wed, 21 Nov 2007 14:38:00 GMT</pubDate><guid>http://www.cppblog.com/DraculaW/archive/2007/11/21/37108.html</guid><wfw:comment>http://www.cppblog.com/DraculaW/comments/37108.html</wfw:comment><comments>http://www.cppblog.com/DraculaW/archive/2007/11/21/37108.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/DraculaW/comments/commentRss/37108.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DraculaW/services/trackbacks/37108.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 对内存分配算法的一点想法 希望大家指正&nbsp;&nbsp;<a href='http://www.cppblog.com/DraculaW/archive/2007/11/21/37108.html'>阅读全文</a><img src ="http://www.cppblog.com/DraculaW/aggbug/37108.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DraculaW/" target="_blank">DraculaW</a> 2007-11-21 22:38 <a href="http://www.cppblog.com/DraculaW/archive/2007/11/21/37108.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>deque 双向队列</title><link>http://www.cppblog.com/DraculaW/archive/2007/11/20/37048.html</link><dc:creator>DraculaW</dc:creator><author>DraculaW</author><pubDate>Tue, 20 Nov 2007 14:30:00 GMT</pubDate><guid>http://www.cppblog.com/DraculaW/archive/2007/11/20/37048.html</guid><wfw:comment>http://www.cppblog.com/DraculaW/comments/37048.html</wfw:comment><comments>http://www.cppblog.com/DraculaW/archive/2007/11/20/37048.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DraculaW/comments/commentRss/37048.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DraculaW/services/trackbacks/37048.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 大概的介绍了下deque的实现<br>为什么要用这种实现方式 谁能解释一下&nbsp;&nbsp;<a href='http://www.cppblog.com/DraculaW/archive/2007/11/20/37048.html'>阅读全文</a><img src ="http://www.cppblog.com/DraculaW/aggbug/37048.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DraculaW/" target="_blank">DraculaW</a> 2007-11-20 22:30 <a href="http://www.cppblog.com/DraculaW/archive/2007/11/20/37048.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>判断两个类型是否有转换的机制的代码</title><link>http://www.cppblog.com/DraculaW/archive/2007/11/15/36717.html</link><dc:creator>DraculaW</dc:creator><author>DraculaW</author><pubDate>Thu, 15 Nov 2007 12:45:00 GMT</pubDate><guid>http://www.cppblog.com/DraculaW/archive/2007/11/15/36717.html</guid><wfw:comment>http://www.cppblog.com/DraculaW/comments/36717.html</wfw:comment><comments>http://www.cppblog.com/DraculaW/archive/2007/11/15/36717.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DraculaW/comments/commentRss/36717.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DraculaW/services/trackbacks/36717.html</trackback:ping><description><![CDATA[template&lt;typename T, typename U&gt;<br>
class Conversion<br>
{<br>
&nbsp;&nbsp;&nbsp;   typedef char Small;<br>
&nbsp;&nbsp;&nbsp;   class Big{char dummy[2];};<br>
&nbsp;&nbsp;&nbsp;   static Small Test(U)&nbsp;&nbsp;&nbsp;   {&nbsp;&nbsp;    }&nbsp;&nbsp;    <br>
&nbsp;&nbsp;&nbsp;   static Big Test(...)  { }&nbsp;&nbsp;    <br>
&nbsp;&nbsp;&nbsp;   static T MakeT()  {  }<br>
&nbsp;&nbsp;&nbsp;   <br>
public:<br>
&nbsp;&nbsp;&nbsp;   enum { exists = sizeof(Test(MakeT())) == sizeof(Small)};&nbsp;&nbsp;&nbsp;   <br>
};<br><br>
如果T可以转换为U 于是就调用Test(U)这个函数 返回一个char；<br>
如果不能 就调用使用(...)缺省参数的函数  返回一个数组<br>
<br>
然后对返回值进行判断....<img src ="http://www.cppblog.com/DraculaW/aggbug/36717.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DraculaW/" target="_blank">DraculaW</a> 2007-11-15 20:45 <a href="http://www.cppblog.com/DraculaW/archive/2007/11/15/36717.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>STL与boost的type traits</title><link>http://www.cppblog.com/DraculaW/archive/2007/11/15/36716.html</link><dc:creator>DraculaW</dc:creator><author>DraculaW</author><pubDate>Thu, 15 Nov 2007 12:43:00 GMT</pubDate><guid>http://www.cppblog.com/DraculaW/archive/2007/11/15/36716.html</guid><wfw:comment>http://www.cppblog.com/DraculaW/comments/36716.html</wfw:comment><comments>http://www.cppblog.com/DraculaW/archive/2007/11/15/36716.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DraculaW/comments/commentRss/36716.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DraculaW/services/trackbacks/36716.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: STL与boost的type traits&nbsp;&nbsp;<a href='http://www.cppblog.com/DraculaW/archive/2007/11/15/36716.html'>阅读全文</a><img src ="http://www.cppblog.com/DraculaW/aggbug/36716.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DraculaW/" target="_blank">DraculaW</a> 2007-11-15 20:43 <a href="http://www.cppblog.com/DraculaW/archive/2007/11/15/36716.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>將foobar的播放列表中的文件整理起來的perl代碼</title><link>http://www.cppblog.com/DraculaW/archive/2007/11/15/36715.html</link><dc:creator>DraculaW</dc:creator><author>DraculaW</author><pubDate>Thu, 15 Nov 2007 12:41:00 GMT</pubDate><guid>http://www.cppblog.com/DraculaW/archive/2007/11/15/36715.html</guid><wfw:comment>http://www.cppblog.com/DraculaW/comments/36715.html</wfw:comment><comments>http://www.cppblog.com/DraculaW/archive/2007/11/15/36715.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DraculaW/comments/commentRss/36715.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DraculaW/services/trackbacks/36715.html</trackback:ping><description><![CDATA[# The readfpl accept a file's path while is fpl(foobar play list),<br>
# and return a list which holds all the file'path <br>
sub readfpl<br>
{<br>
&nbsp;&nbsp;&nbsp;  my @files;<br>
&nbsp;&nbsp;&nbsp;  my @chunks;<br>
&nbsp;&nbsp;&nbsp;  my $index = 0;<br>
<br>
&nbsp;&nbsp;&nbsp;  open(INPUT, "&lt; $_[0]")<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  or die "can't open";<br>
<br>
&nbsp;&nbsp;&nbsp;   @chunks = split(m{file://}, &lt;INPUT&gt;);<br>
<br>
&nbsp;&nbsp;&nbsp;  foreach(@chunks)<br>
&nbsp;&nbsp;&nbsp;  {&nbsp;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  if($_ =~ m/.+\.(mp3|wma|m4a)/)<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  {<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  $files[$index] = $&amp;;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  $index ++;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
&nbsp;&nbsp;&nbsp;  }<br>
<br>
&nbsp;&nbsp;&nbsp;  print $files[0];<br>
&nbsp;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  return @files;<br>
}<br>
<br>
my @files = readfpl($ARGV[0]);<br>
my $string;<br>
<br>
foreach(@files){<br>
&nbsp;&nbsp;&nbsp;&nbsp;  $string = $_;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  # the next while get name from path<br>
&nbsp;&nbsp;&nbsp;&nbsp;  while( substr($string, 1) =~ m{\\.+\.(mp3|wna|m4a)}) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  $string = $ARGV[0].$&amp;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
&nbsp;&nbsp;&nbsp;&nbsp;  rename $_, string;<br>
}<br>
<br>
將這段代碼存為movefpl.pl然后在命令行打入 movefpl.pl 播放列表的全路徑 要存歌曲的新路徑<br>
就可以了呢 呵呵<img src ="http://www.cppblog.com/DraculaW/aggbug/36715.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DraculaW/" target="_blank">DraculaW</a> 2007-11-15 20:41 <a href="http://www.cppblog.com/DraculaW/archive/2007/11/15/36715.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>还是大学的作业</title><link>http://www.cppblog.com/DraculaW/archive/2007/11/15/36714.html</link><dc:creator>DraculaW</dc:creator><author>DraculaW</author><pubDate>Thu, 15 Nov 2007 12:40:00 GMT</pubDate><guid>http://www.cppblog.com/DraculaW/archive/2007/11/15/36714.html</guid><wfw:comment>http://www.cppblog.com/DraculaW/comments/36714.html</wfw:comment><comments>http://www.cppblog.com/DraculaW/archive/2007/11/15/36714.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DraculaW/comments/commentRss/36714.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DraculaW/services/trackbacks/36714.html</trackback:ping><description><![CDATA[Assessing Infection<br>
<br>
<h3>Background</h3>
<p>According to the World Health Organization, infectious disease ranks
as the leading cause of death in the world. In 1998 alone, over 17
million people died from infectious and parasitic diseases such as
acute lower respiratory infections, tuberculosis, HIV/AIDS, and
malaria. It is forecast that infectious disease will continue to kill
millions of people, especially those living in developing countries.</p>
<p>The medical profession and scientific community of the world are
fighting the infectious disease threat with new tools and technologies
from a variety of fields. From this effort, a new field of research has
emerged. <dfn>Infectious  Disease Epidemiology</dfn> is the study of
the variables that influence the growth and spread of infectious
diseases. This relatively new field combines molecular biology,
immunology, genetics, and the computational sciences. A focus of this
field is the study of the factors that influence the growth of an
infectious disease within a single organism, and the factors that
influence the pattern of infection across an entire population. </p>
<h3>Description</h3>
<p>This assignment asks you to finish the implementation of a program
that assesses the level of infection in a tissue sample. You are given
data representing a rectangular tissue sample, overlaid with a grid.
Certain portions of the tissue are infected; others are not. Your goal
is to help assess the extent of the infection by writing a program
that, given the coordinates of a colony of infection, can determine its
size. </p>
<p>A typical use of the program follows. The user interacts with the
program only through command-line arguments. The user supplies to the
program a data filename and the coordinates of a cell in the grid. The
coordinates are specified by row and then column, both starting at
zero. The program calculates the extent of infection at that coordinate
and outputs a two-dimensional representation of the tissue sample.
Figure 1 depicts the execution of the program. </p>
<blockquote><img  src="http://hi.baidu.com/draculaw/blog/item/396_files/screenshot%5B2%5D.jpg" alt="A screen shot from a sample solution" border="0"><br>
<span class="example-caption-title-header">Figure 1</span> <span class="example-caption-title-body">Output from a sample solution</span>  </blockquote>
<p>For the purpose of this assessment, we consider a "colony" of
infected tissue to be a set of adjacent and infected cells. In Figure
1, we can see three separate colonies. The smallest colony consists of
two cells and is located in the lower left corner of the grid. Another
colony consisting of three infected cells exists on the far right edge
of the grid. The largest colony of eight cells resides primarily in the
middle of the grid. This colony has a small arm into the upper left
corner of the grid. Notice from this colony that cells residing in
diagonals are considered "adjacent." The plus signs next to the cells
in this largest colony indicate that they all belong to the colony that
contains the user entered coordinate.</p>
<br>
<span class="example-caption-title-body">solution</span> :<br>
<br>
#ifndef GRID_H<br>
#define GRID_H<br>
<br>
#include &lt;string&gt;<br>
#include &lt;vector&gt;<br>
<br>
using namespace std;<br>
<br>
/*<br>
* IMPORTANT NOTE:<br>
*<br>
* For this assignment, you might need to add state to the <br>
* class and/or augment existing methods, and/or create private helper <br>
* methods, but you should not delare new public methods<br>
*/<br>
<br>
const bool INFECTED = true;<br>
const bool NOT_INFECTED = false;<br>
<br>
class grid;<br>
<br>
class grid {<br>
<br>
private:<br>
&nbsp;&nbsp;&nbsp;  int rows;<br>
&nbsp;&nbsp;&nbsp;  int cols;<br>
&nbsp;&nbsp;&nbsp;  vector&lt;bool&gt; *area;<br>
&nbsp;&nbsp;&nbsp;  vector&lt;bool&gt; *infect;<br>
&nbsp;&nbsp;&nbsp;  int indexof (int row, int col) const;<br>
&nbsp;&nbsp;&nbsp;  bool infected(int row, int col) const;<br>
<br>
public:<br>
&nbsp;&nbsp;&nbsp;  grid (string file);<br>
&nbsp;&nbsp;&nbsp;  ~grid ();<br>
<br>
&nbsp;&nbsp;&nbsp;  int count (int row, int col);<br>
<br>
&nbsp;&nbsp;&nbsp;  friend ostream &amp;operator&lt;&lt;(ostream &amp;stream, const grid&amp; ob);<br>
<br>
};<br>
<br>
#endif <br>
<br>
============================================================================<br>
<br>
#include &lt;iostream&gt;<br>
#include &lt;fstream&gt;<br>
<br>
using namespace std;<br>
<br>
#include "grid.h"<br>
<br>
// You do not need to alter function indexof.<br>
int grid::indexof (int row, int col) const {<br>
&nbsp;&nbsp;&nbsp;  return row*cols+col;<br>
}<br>
<br>
// You do not need to alter function infected.<br>
bool grid::infected(int row, int col) const {<br>
&nbsp;&nbsp;&nbsp;  return (area-&gt;operator[](indexof(row, col)) == INFECTED);<br>
}<br>
<br>
// You may need to alter the constructor<br>
grid::grid (string file) {<br>
<br>
&nbsp;&nbsp;&nbsp;  ifstream grid_file;<br>
<br>
&nbsp;&nbsp;&nbsp;  grid_file.open (file.c_str());<br>
<br>
&nbsp;&nbsp;&nbsp;  grid_file &gt;&gt; rows;<br>
&nbsp;&nbsp;&nbsp;  grid_file &gt;&gt; cols;<br>
<br>
&nbsp;&nbsp;&nbsp;  area = new vector&lt;bool&gt;(rows*cols, NOT_INFECTED);<br>
&nbsp;&nbsp;&nbsp;  infect = new vector&lt;bool&gt;(rows*cols, NOT_INFECTED);<br>
&nbsp;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  while (true) { <br>
<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  int blob_row;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  int blob_col;<br>
<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  grid_file &gt;&gt; blob_row;  <br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  grid_file &gt;&gt; blob_col;  <br>
<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  if (grid_file.eof()) {<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  break;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  area-&gt;operator[](indexof(blob_row,blob_col)) = INFECTED;<br>
&nbsp;&nbsp;&nbsp;  }<br>
<br>
&nbsp;&nbsp;&nbsp;  grid_file.close();<br>
}<br>
<br>
// You may need to alter the destructor<br>
grid::~grid () {<br>
&nbsp;&nbsp;&nbsp;  delete area;<br>
&nbsp;&nbsp;&nbsp;  delete infect;<br>
}<br>
<br>
// You will need to alter this function to display the<br>
// plus signs (+) next to the cells that belong to<br>
// a counted colony.<br>
ostream &amp;operator&lt;&lt;(ostream &amp;stream, const grid&amp; ob) {<br>
<br>
&nbsp;&nbsp;&nbsp;  for (int row=0; row &lt; ob.rows; row++) { <br>
&nbsp;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  for (int col=0; col &lt; ob.cols; col++) {<br>
<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  stream &lt;&lt; ob.area-&gt;operator[](ob.indexof(row, col));<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  if( ob.infect-&gt;operator[] ( ob.indexof(row, col) ) )<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  stream &lt;&lt; "+  ";<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  else<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  stream &lt;&lt; "&nbsp;&nbsp;  ";<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  stream &lt;&lt; endl;<br>
&nbsp;&nbsp;&nbsp;  }<br>
<br>
&nbsp;&nbsp;&nbsp;  stream &lt;&lt; endl;<br>
&nbsp;&nbsp;&nbsp;  return stream;<br>
}<br>
<br>
// Replace the return statement in this function with your<br>
// recursive implementation of this method */<br>
int grid::count (int row, int col) {<br>
<br>
&nbsp;&nbsp;&nbsp;  if( row &lt; 0 || col &lt; 0 || row == rows || col == cols)<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  return 0;<br>
<br>
&nbsp;&nbsp;&nbsp;  if( area-&gt;operator[](indexof(row,col) ) == NOT_INFECTED )<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  return 0;<br>
<br>
&nbsp;&nbsp;&nbsp;  if(infect-&gt;operator[](indexof(row,col)) == INFECTED)<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  return 0;<br>
<br>
&nbsp;&nbsp;&nbsp;  infect-&gt;operator[](indexof(row,col)) = INFECTED;<br>
<br>
&nbsp;&nbsp;&nbsp;  // Recursive test the 8 point near the point<br>
&nbsp;&nbsp;&nbsp;  // which area is INEFCTED and infect is NOT_INFECTED<br>
<br>
&nbsp;&nbsp;&nbsp;  return&nbsp;&nbsp;&nbsp;  count( row - 1, col - 1 ) + count ( row - 1, col )<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  + count( row - 1, col + 1 ) + count( row, col - 1 )<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  + count( row, col ) + 1 + count( row, col + 1 )<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  + count( row + 1, col - 1 ) + count( row + 1, col )<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  + count( row + 1, col + 1 );<br>
}<img src ="http://www.cppblog.com/DraculaW/aggbug/36714.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DraculaW/" target="_blank">DraculaW</a> 2007-11-15 20:40 <a href="http://www.cppblog.com/DraculaW/archive/2007/11/15/36714.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>大学时期的一道作业题</title><link>http://www.cppblog.com/DraculaW/archive/2007/11/15/36712.html</link><dc:creator>DraculaW</dc:creator><author>DraculaW</author><pubDate>Thu, 15 Nov 2007 12:39:00 GMT</pubDate><guid>http://www.cppblog.com/DraculaW/archive/2007/11/15/36712.html</guid><wfw:comment>http://www.cppblog.com/DraculaW/comments/36712.html</wfw:comment><comments>http://www.cppblog.com/DraculaW/archive/2007/11/15/36712.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DraculaW/comments/commentRss/36712.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DraculaW/services/trackbacks/36712.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 一道简单的作业贴 呵呵 &nbsp;&nbsp;<a href='http://www.cppblog.com/DraculaW/archive/2007/11/15/36712.html'>阅读全文</a><img src ="http://www.cppblog.com/DraculaW/aggbug/36712.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DraculaW/" target="_blank">DraculaW</a> 2007-11-15 20:39 <a href="http://www.cppblog.com/DraculaW/archive/2007/11/15/36712.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>手機輸入法的一個算法--哈希真是一種好算法</title><link>http://www.cppblog.com/DraculaW/archive/2007/11/15/36710.html</link><dc:creator>DraculaW</dc:creator><author>DraculaW</author><pubDate>Thu, 15 Nov 2007 12:37:00 GMT</pubDate><guid>http://www.cppblog.com/DraculaW/archive/2007/11/15/36710.html</guid><wfw:comment>http://www.cppblog.com/DraculaW/comments/36710.html</wfw:comment><comments>http://www.cppblog.com/DraculaW/archive/2007/11/15/36710.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DraculaW/comments/commentRss/36710.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DraculaW/services/trackbacks/36710.html</trackback:ping><description><![CDATA[手機的英文智能輸入法其實很簡單的想法 使用哈希來實現 呵呵<br>
<br>
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   3<br>
,.&nbsp;&nbsp;&nbsp;   abc&nbsp;&nbsp;&nbsp;   def<br>
<br>
4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   6<br>
ghi&nbsp;&nbsp;&nbsp;   jkl&nbsp;&nbsp;&nbsp;   mno<br>
<br>
7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  8&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;       9<br>
pqrs tuv&nbsp;&nbsp;  wxyz<br>
<br>
譬如說輸入 43<br>
進入這個哈希里面去尋找<br>
key[43] -&gt; [if] -&gt; [he] -&gt; [id] -&gt; [ie]-&gt; [ge] -&gt; [gf] -&gt; 0<br>
還可以輸入更多的 呵呵。<br>
<br>
以此類推，如果是拼音輸入也是一樣，只不過要多進行一次哈希。從拼音哈希到具體的漢字里面去。<br>
<br>
不過拼音輸入的狀態機應該更復雜一些。因為拼音輸入可以根據前一個字來推斷可能出現的下一個字。<br>
<br>
其實 不只是手機，只要是使用數字鍵盤的機器都可以使用這樣子的輸入法。<br>
<br>
使用這種算法的變種還可以實現一個好玩的游戲：就是輸入一個單詞，然后輸出所有與它組成元素相同的單詞(就是輸入stop 它可以輸出tops等單詞)。具體也是使用哈希。哈希真是一個好算法<img src ="http://www.cppblog.com/DraculaW/aggbug/36710.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DraculaW/" target="_blank">DraculaW</a> 2007-11-15 20:37 <a href="http://www.cppblog.com/DraculaW/archive/2007/11/15/36710.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>