<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dutor &#187; 译文</title>
	<atom:link href="http://www.dutor.net/index.php/tag/translation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dutor.net</link>
	<description>熟读而精思，循序而渐进，厚积而薄发。</description>
	<lastBuildDate>Tue, 17 Jan 2012 14:44:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>C++编译器的选择</title>
		<link>http://www.dutor.net/index.php/2009/05/selection-of-cplusplus-complilers/</link>
		<comments>http://www.dutor.net/index.php/2009/05/selection-of-cplusplus-complilers/#comments</comments>
		<pubDate>Wed, 13 May 2009 14:17:53 +0000</pubDate>
		<dc:creator>dutor</dc:creator>
				<category><![CDATA[之语言特性]]></category>
		<category><![CDATA[Cpp]]></category>
		<category><![CDATA[程序应用]]></category>
		<category><![CDATA[译文]]></category>

		<guid isPermaLink="false">http://www.dutor.net/?p=449</guid>
		<description><![CDATA[
<blockquote>经常有人要我(Bjarne Stroustrup)推荐一种C++的编译器。但是，我通常不会推荐任何编译器，因为我可能因此而在编译器的商战中表明"立场"。而且我并不是对所有的编译器都了解，C++编译器实在是太多了，我平时会用到半打(6个)C++ 编译器，但那只是"沧海一粟"罢了。
我希望人们在选择自己的编译器时，一定要严格参照现行的C++标准。尽量避免使用不支持或者违背ISO标准的编译器。
你如果是一个初学者而且不知道如何测验一个编译器是否符合标准的话，你可以试试下面这个小程序:</blockquote>
]]></description>
			<content:encoded><![CDATA[<blockquote><p>经常有人要我(Bjarne Stroustrup)推荐一种C++的编译器。但是，我通常不会推荐任何编译器，因为我可能因此而在编译器的商战中表明&#8221;立场&#8221;。而且我并不是对所有的编译器都了解，C++编译器实在是太多了，我平时会用到半打(6个)C++ 编译器，但那只是&#8221;沧海一粟&#8221;罢了。<br />
我希望人们在选择自己的编译器时，一定要严格参照现行的C++标准。尽量避免使用不支持或者违背ISO标准的编译器。<br />
你如果是一个初学者而且不知道如何测验一个编译器是否符合标准的话，你可以试试下面这个小程序:</p></blockquote>

<div class="wp_codebox"><table><tr id="p4491"><td class="code" id="p449code1"><pre class="cpp" style="font-family:monospace;">        <span style="color: #339900;">#include &lt;iostream&gt;</span>
	<span style="color: #339900;">#include &lt;string&gt;</span>
&nbsp;
	<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		string s<span style="color: #008080;">;</span>
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Please enter your first name followed by a newline<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
		<span style="color: #0000dd;">cin</span> <span style="color: #000080;">&gt;&gt;</span> s<span style="color: #008080;">;</span>
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Hello, &quot;</span> <span style="color: #000080;">&lt;&lt;</span> s <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> <span style="color: #666666;">// this return statement isn't necessary</span>
	<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<blockquote><p>假如你的编译器无法正常运行这段简单的代码的话，那么它不应该是你学习标准C++的一种好的选择。<br />
虽然有些过时，但还是要推荐一篇较详尽的介绍标准的文章和boost.org的编译器的页面。符合标准只是评价一个编译器品质的一个方面，其他还包括:生成代码的质量，生成的错误信息，编译速度，集成的工具，厂商支持的力度，向后兼容性等等等等。不过，和标准的一致性确实是相当重要的一个方面。另外，一些编译器提供它自己对语言的一些扩展，使用这些扩展的特性将降低你的代码的可移植性，当你换用其他编译器是也会比较困难。<br />
当在网络上寻找编译器时，你会发现，很多信息被各种各样的产品名称掩盖了。这里，我搜集了一些C++编译器。其中有一些是可以免费下载的：</p></blockquote>
<ul>
<li> <a href="http://developer.apple.com/tools/macosxtools.html">Apple C++</a>. It also comes with OS X on the developer tools CD.</li>
<li> <a href="http://www.bloodshed.net/devcpp.html">Bloodshed Dev-C++</a>. A GCC-based (Mingw) IDE.</li>
<li> <a href="http://www.borland.com/downloads/download_cbuilder.html">Borland C++</a></li>
<li> <a href="http://www.cygwin.com/">Cygwin (GNU C++)</a></li>
<li> <a href="http://www.digitalmars.com/">Digital Mars C++</a></li>
<li> <a href="http://www.mingw.org/">MINGW &#8211; &#8220;Minimalist GNU for Windows&#8221;</a>. Another GCC version for Windows including a free (non-GPL) w32api.</li>
<li> <a href="http://www.delorie.com/djgpp">DJ Delorie&#8217;s C++ development system for DOS/Windows (GNU C++)</a></li>
<li> <a href="http://www.gnu.org/software/gcc/gcc.html">GNU CC source</a></li>
<li> <a href="http://www-949.ibm.com/software/rational/cafe/community/ccpp">IBM C++</a> for IBM power, System Z, Bluegene, and Cell.</li>
<li> <a href="http://www.intel.com/software/products/compilers/clin/noncom.htm">Intel C++ for linux</a></li>
<li> <a href="http://llvm.cs.uiuc.edu/">The LLVM Compiler Infrastructure</a> (based on GCC).</li>
<li> <a href="http://www.microsoft.com/express/vc">Microsoft Visual C++ 2008 Express edition</a>.</li>
<li> <a href="http://developers.sun.com/sunstudio">Sun Studio</a>.</li>
</ul>
<blockquote><p>另外一些是需要付费才可使用的：</p></blockquote>
<ul>
<li> <a href="http://www.borland.com/bcppbuilder/">Borland C++</a></li>
<li> <a href="http://www.metrowerks.com/products/macos/">CodeWarrior C++</a> (formerly Metrowerks), it comes for many platforms.</li>
<li> <a href="http://www.comeaucomputing.com/">Comeau C++</a> for many platforms</li>
<li> <a href="http://www.edg.com/cpp.html">Edison Design Group C++ Front End</a> &#8211; used by <a href="http://www.edg.com/resellers.html">many C++ compiler suppliers</a></li>
<li> <a href="http://www.ghs.com/products/optimizingC++EC++Compilers.html">Green Hills C++</a> for many embedded systems platforms</li>
<li> <a href="http://www.hp.com/go/cpp/">HP C++ for Unix</a> and <a href="http://h71000.www7.hp.com/commercial/cplus/cplus_index.html">HP C++ for OpenVMS</a>.</li>
<li> <a href="http://www.intel.com/software/products/compilers/">Intel C++</a> for Windows, Linux, and some embedded systems.</li>
<li> <a href="http://www.mentorgraphics.com/embedded/compilers/index.html">Mentor Graphics/Microtec Research C++</a> for many embedded systems platforms</li>
<li> <a href="http://msdn.microsoft.com/visualc">Microsoft C++</a></li>
<li> <a href="http://www.devtools.com/">Paradigm C++</a>, for x86 embedded systems</li>
<li> <a href="http://www.pgroup.com/prodworkpgcc.htm">The Portland Group C++</a> (parallization for Pentiums)</li>
<li> <a href="http://www.sgi.com/products/software/irix/tools/c++.html">SGI C++</a>, optimizing compiler</li>
<li> <a href="http://www.sun.com/forte/cplusplus/index.html">Sun C++</a></li>
<li> <a href="http://www.windriver.com/products/">WindRiver&#8217;s Diab C++</a> used in many embedded systems.</li>
</ul>
<p>[tip]This is a translation from <a href="http://www.research.att.com/~bs/compilers.html">Bjarne Stroustroup</a>[/tip]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dutor.net/index.php/2009/05/selection-of-cplusplus-complilers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>插入法排序</title>
		<link>http://www.dutor.net/index.php/2009/05/insertion-sorting/</link>
		<comments>http://www.dutor.net/index.php/2009/05/insertion-sorting/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 23:16:16 +0000</pubDate>
		<dc:creator>dutor</dc:creator>
				<category><![CDATA[之算法神奇]]></category>
		<category><![CDATA[排序]]></category>
		<category><![CDATA[译文]]></category>

		<guid isPermaLink="false">http://www.dutor.net/?p=326</guid>
		<description><![CDATA[
<strong>算法：</strong>
<pre lang="cpp" line="1">
for i = 2:n,
    for (k = i; k > 1 and a[k] < a[k-1]; k--) 
        swap a[k,k-1]
    → invariant: a[1..i] is sorted
end
</pre>
<strong>算法性质：</strong>
<ul>
	<li>稳定</li>
	<li>需要O(1)的额外空间开销</li>
	<li>需要O(n<sup>2</sup>)复杂度的比较和交换。</li>
	<li>具有自适应性：当待排序序列接近有序时，复杂度为O(n)。</li>
	<li>开销较低</li>
</ul>
<strong>讨论：</strong>


<blockquote>
虽然在最坏情况下，插入法排序的复杂度为O(n<sup>2</sup>)，但当序列已经接近有序(算法具有自适应性)或者问题规模比较小(空间开销很小)时，插入法排序还是一种比较好的选择。所以，插入法排序，通常可以作为其他诸如归并排序、快速排序等递归递归排序的基础。
</blockquote>
]]></description>
			<content:encoded><![CDATA[<p><strong>算法：</strong></p>

<div class="wp_codebox"><table><tr id="p3262"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p326code2"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">for</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">:</span>n,
    <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span>k <span style="color: #000080;">=</span> i<span style="color: #008080;">;</span> k <span style="color: #000080;">&gt;</span> <span style="color: #0000dd;">1</span> and a<span style="color: #008000;">&#91;</span>k<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&lt;</span> a<span style="color: #008000;">&#91;</span>k<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span> k<span style="color: #000040;">--</span><span style="color: #008000;">&#41;</span> 
        swap a<span style="color: #008000;">&#91;</span>k,k<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span>
    → invariant<span style="color: #008080;">:</span> a<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span>..<span style="color: #007788;">i</span><span style="color: #008000;">&#93;</span> is sorted
end</pre></td></tr></table></div>

<p><strong>算法性质：</strong></p>
<ul>
<li>稳定</li>
<li>需要O(1)的额外空间开销</li>
<li>需要O(n<sup>2</sup>)复杂度的比较和交换。</li>
<li>具有自适应性：当待排序序列接近有序时，复杂度为O(n)。</li>
<li>开销较低</li>
</ul>
<p><strong>讨论：</strong></p>
<blockquote><p>
虽然在最坏情况下，插入法排序的复杂度为O(n<sup>2</sup>)，但当序列已经接近有序(算法具有自适应性)或者问题规模比较小(空间开销很小)时，插入法排序还是一种比较好的选择。所以，插入法排序，通常可以作为其他诸如归并排序、快速排序等递归递归排序的基础。
</p></blockquote>
<p>[tip]<br />
关于自适应性的一种解释：自适应性是指特定条件下形状结构及过程自身的趋向性.<br />
[/tip]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dutor.net/index.php/2009/05/insertion-sorting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

