﻿<?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++博客-The Fourth Dimension Space</title><link>http://www.cppblog.com/abilitytao/</link><description>枯叶北风寒，忽然年以残，念往昔，语默心酸。二十光阴无一物，韶光贱，寐难安； 不畏形影单，道途阻且慢，哪曲折，如渡飞湍。斩浪劈波酬壮志，同把酒，共言欢！  -如梦令</description><language>zh-cn</language><lastBuildDate>Sat, 04 Apr 2026 12:38:52 GMT</lastBuildDate><pubDate>Sat, 04 Apr 2026 12:38:52 GMT</pubDate><ttl>60</ttl><item><title>人生的高度不在于你学会了什么技术，会做什么事，而取决于价值观(value)与远见(vision)</title><link>http://www.cppblog.com/abilitytao/archive/2016/12/31/214568.html</link><dc:creator>abilitytao</dc:creator><author>abilitytao</author><pubDate>Sat, 31 Dec 2016 14:01:00 GMT</pubDate><guid>http://www.cppblog.com/abilitytao/archive/2016/12/31/214568.html</guid><wfw:comment>http://www.cppblog.com/abilitytao/comments/214568.html</wfw:comment><comments>http://www.cppblog.com/abilitytao/archive/2016/12/31/214568.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/abilitytao/comments/commentRss/214568.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/abilitytao/services/trackbacks/214568.html</trackback:ping><description><![CDATA[待写<img src ="http://www.cppblog.com/abilitytao/aggbug/214568.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/abilitytao/" target="_blank">abilitytao</a> 2016-12-31 22:01 <a href="http://www.cppblog.com/abilitytao/archive/2016/12/31/214568.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>什么是市盈率或称本益比(P/E Ratio)？</title><link>http://www.cppblog.com/abilitytao/archive/2015/01/05/209399.html</link><dc:creator>abilitytao</dc:creator><author>abilitytao</author><pubDate>Mon, 05 Jan 2015 09:20:00 GMT</pubDate><guid>http://www.cppblog.com/abilitytao/archive/2015/01/05/209399.html</guid><wfw:comment>http://www.cppblog.com/abilitytao/comments/209399.html</wfw:comment><comments>http://www.cppblog.com/abilitytao/archive/2015/01/05/209399.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/abilitytao/comments/commentRss/209399.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/abilitytao/services/trackbacks/209399.html</trackback:ping><description><![CDATA[<pre id="best-content-1507341528" accuse="aContent"  mb-10"="" style="margin-top: 0px; margin-bottom: 10px; padding: 0px; font-family: arial, 'courier new', courier, 宋体, monospace; white-space: pre-wrap; word-wrap: break-word; color: #333333; line-height: 24px; background-color: #f1fedd;"><div>本益比是选股票的重要指标之一，说起本益比这个词，相信很多人都有听过，大部分投资者也自认明白和了解本益比的含义，但当你叫他和你解释时，他却说了半天你也没听懂。 一开始我也以为自己明白和了解本益比，因为本身读金融系的关系，我知道本益比的计算方式，但最近我终于明白，知道计算本益比和了解本益比是两回事，方程式始终只是方程式，必须探讨其中的含义，了解方程式的的由来，才能一探本益比的真实意义，让本益比成为选股的武器。 首先先放百度百科的本益比含义：<br />本益比（price/earning，简称P/E） 本益比是某种股票普通股每股市价（股价）与每股盈利的比率。也称&#8220;股价收益比率&#8221;或&#8220;市价盈利比率（简称市盈率）&#8221;。英文用PER表示。其计算公式为：本益比=股票市价/每股纯利（年） <br />本益比是某种股票普通股每股市价与每股盈利的比率。所以它也称为股价收益比率或市价盈利比率。 如此，本益比应该是通常所说的市盈率。 <br />马来西亚和新加坡财经报章一般将其称为&#8220;本益比&#8221;，而香港和中国一般称作&#8220;市盈率&#8221;，其实只是称呼不同，但内容和含义相同，英文则称为P/E RATIO或者PER，就是PRICE/EARNING RATIO的缩写。 <br />本益比的计算方式： <br />Market Value per Share（股票当今价格）<br />Earnings per Share (EPS)（每股盈利） <br />股票当今价格也就是股票闭市的价格。 <br />每股盈利则是公司盈利除于股票数量。 <br />例子：一间上市公司拥有100万股，2012年度公司盈利为50万。 <br />每股盈利就等于 50万&#247;100万 = 0.50 （每股分得0.50的盈利） <br />EPS(Earning Per Share) 就是0.50 <br />如果该公司闭市价格为RM2.00 本益比就是2.00/0.50 = 4倍 <br />用白话解释本益比，一句就搞定了： 本益比其实就是回本年份，如果该股本益比为4倍，代表我们购买该股，4年才能回本。 <br />股价就好比你的投资额，EPS就是我们的回报。 如果该股闭市价格RM2.00，我们购买该股本钱就RM2.00，EPS就是我们的回报，如果该股EPS是0.50，代表我们投资RM2.00，每年能拿回0.50，要4年才能回本，这4年其实就是我们常说的本益比。<br />预测本益比就是根据该公司今年的盈利，预测明年的盈利，再计算出来的本益比。 本益比其实就是回本年份，如果该公司没有盈利，你永远都不能回本，那么该公司就不会有本益比。 马航就是没有本益比的最好例子。 很多人可能会说，如果本益比代表回本年份，那么是不是越低越好？那么就表示越快回本。 其实不然，本益比虽然是代表着回本年份，但不一定越低越好，要视公司而定，很多蓝筹股的本益比都很高，也有很多垃圾股本益比都很低。 一般上互联网科技股的本益比都很高。 马来西亚基本面大师冷眼觉得本益比在10以下的公司，都比较合理，本益比超过10，该股有被高估的可能。<br />转自百度知道。</div></pre><img src ="http://www.cppblog.com/abilitytao/aggbug/209399.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/abilitytao/" target="_blank">abilitytao</a> 2015-01-05 17:20 <a href="http://www.cppblog.com/abilitytao/archive/2015/01/05/209399.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>WebSocket的一些资料</title><link>http://www.cppblog.com/abilitytao/archive/2014/11/19/208927.html</link><dc:creator>abilitytao</dc:creator><author>abilitytao</author><pubDate>Wed, 19 Nov 2014 14:13:00 GMT</pubDate><guid>http://www.cppblog.com/abilitytao/archive/2014/11/19/208927.html</guid><wfw:comment>http://www.cppblog.com/abilitytao/comments/208927.html</wfw:comment><comments>http://www.cppblog.com/abilitytao/archive/2014/11/19/208927.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/abilitytao/comments/commentRss/208927.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/abilitytao/services/trackbacks/208927.html</trackback:ping><description><![CDATA[<a href="http://www.cnblogs.com/imayi/archive/2012/05/05/2485343.html">http://www.cnblogs.com/imayi/archive/2012/05/05/2485343.html</a><img src ="http://www.cppblog.com/abilitytao/aggbug/208927.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/abilitytao/" target="_blank">abilitytao</a> 2014-11-19 22:13 <a href="http://www.cppblog.com/abilitytao/archive/2014/11/19/208927.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Unix下 压缩和解压缩命令</title><link>http://www.cppblog.com/abilitytao/archive/2014/11/11/208849.html</link><dc:creator>abilitytao</dc:creator><author>abilitytao</author><pubDate>Tue, 11 Nov 2014 15:34:00 GMT</pubDate><guid>http://www.cppblog.com/abilitytao/archive/2014/11/11/208849.html</guid><wfw:comment>http://www.cppblog.com/abilitytao/comments/208849.html</wfw:comment><comments>http://www.cppblog.com/abilitytao/archive/2014/11/11/208849.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/abilitytao/comments/commentRss/208849.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/abilitytao/services/trackbacks/208849.html</trackback:ping><description><![CDATA[范例：&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><span style="color: #3366ff;">.tar&nbsp;</span><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><span style="color: #3366ff;">解包：tar -xvf FileName.tar&nbsp;</span><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><span style="color: #3366ff;">打包：tar -cvf FileName.tar DirName&nbsp;</span><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><span style="color: #3366ff;">（注：tar是打包，不是压缩！）&nbsp;</span><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><span style="color: #3366ff;">---------------------------------------------&nbsp;</span><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><span style="color: #3366ff;">.gz&nbsp;</span><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><span style="color: #3366ff;">解压1：gunzip FileName.gz&nbsp;</span><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><span style="color: #3366ff;">解压2：gzip -d FileName.gz&nbsp;</span><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><span style="color: #3366ff;">压缩：gzip FileName&nbsp;<br /></span><span style="color: #3366ff;">.tar.gz&nbsp;</span><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><span style="color: #3366ff;">解压：tar zxvf FileName.tar.gz&nbsp;</span><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><span style="color: #3366ff;">压缩：tar zcvf FileName.tar.gz DirName&nbsp;</span><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />---------------------------------------------&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.bz2&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解压1：bzip2 -d FileName.bz2&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解压2：bunzip2 FileName.bz2&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />压缩： bzip2 -z FileName&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.tar.bz2&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解压：tar jxvf FileName.tar.bz2&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />压缩：tar jcvf FileName.tar.bz2 DirName&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />---------------------------------------------&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.bz&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解压1：bzip2 -d FileName.bz&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解压2：bunzip2 FileName.bz&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />压缩：未知&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />---------------------------------------------&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.tar.bz&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解压：tar jxvf FileName.tar.bz&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />压缩：未知&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />---------------------------------------------&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.Z&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解压：uncompress FileName.Z&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />压缩：compress FileName&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.tar.Z&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解压：tar Zxvf FileName.tar.Z&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />压缩：tar Zcvf FileName.tar.Z DirName&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />---------------------------------------------&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.tgz&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解压：tar zxvf FileName.tgz&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />压缩：未知&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.tar.tgz&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解压：tar zxvf FileName.tar.tgz&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />压缩：tar zcvf FileName.tar.tgz FileName&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />---------------------------------------------&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.zip&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解压：unzip FileName.zip&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />压缩：zip FileName.zip DirName&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />---------------------------------------------&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.rar&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解压：rar a FileName.rar&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />压缩：rar e FileName.rar&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />---------------------------------------------&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />压缩解压缩&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />zip文件：&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />功能说明：压缩文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />语　　法：zip [-AcdDfFghjJKlLmoqrSTuvVwXyz$][-b &lt;工作目录&gt;][-ll][-n &lt;字尾字符串&gt;][-t &lt;日期时间&gt;][-&lt;压缩效率&gt;][压缩文件][文件...][-i &lt;范本样式&gt;][-x &lt;范本样式&gt;]&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />补充说明：zip是个使用广泛的压缩程序，文件经它压缩后会另外产生具有".zip"扩展名的压缩文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />参　　数：&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-A 调整可执行的自动解压缩文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-b&lt;工作目录&gt; 指定暂时存放文件的目录。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-c 替每个被压缩的文件加上注释。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-d 从压缩文件内删除指定的文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-D 压缩文件内不建立目录名称。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-f 此参数的效果和指定"-u"参数类似，但不仅更新既有文件，如果某些文件原本不存在于压缩文件内，使用本参数会一并将其加入压缩文件中。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-F 尝试修复已损坏的压缩文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-g 将文件压缩后附加在既有的压缩文件之后，而非另行建立新的压缩文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-h 在线帮助。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-i&lt;范本样式&gt; 只压缩符合条件的文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-j 只保存文件名称及其内容，而不存放任何目录名称。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-J 删除压缩文件前面不必要的数据。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-k 使用MS-DOS兼容格式的文件名称。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-l 压缩文件时，把LF字符置换成LF+CR字符。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-ll 压缩文件时，把LF+CR字符置换成LF字符。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-L 显示版权信息。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-m 将文件压缩并加入压缩文件后，删除原始文件，即把文件移到压缩文件中。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-n&lt;字尾字符串&gt; 不压缩具有特定字尾字符串的文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-o 以压缩文件内拥有最新更改时间的文件为准，将压缩文件的更改时间设成和该文件相同。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-q 不显示指令执行过程。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-r 递归处理，将指定目录下的所有文件和子目录一并处理。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-S 包含系统和隐藏文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-t&lt;日期时间&gt; 把压缩文件的日期设成指定的日期。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-T 检查备份文件内的每个文件是否正确无误。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-u 更换较新的文件到压缩文件内。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-v 显示指令执行过程或显示版本信息。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-V 保存VMS操作系统的文件属性。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-w 在文件名称里假如版本编号，本参数仅在VMS操作系统下有效。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-x&lt;范本样式&gt; 压缩时排除符合条件的文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-X 不保存额外的文件属性。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-y 直接保存符号连接，而非该连接所指向的文件，本参数仅在UNIX之类的系统下有效。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-z 替压缩文件加上注释。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-$ 保存第一个被压缩文件所在磁盘的卷册名称。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-&lt;压缩效率&gt; 压缩效率是一个介于1-9的数值。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />rar文件：&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />Rar 用法: rar ＜命令＞ -＜选项1＞ ....-＜选项N＞ ＜操作文档＞ ＜文件...＞ ＜@文件列表...＞ ＜解压路径＞ h/](J k!P x l"w:G v K q7i6v&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　通常rar命令由一个主命令加若干选项（可选）构成，操作文档为操作施加的.rar文件对象，文件或文件列表为对操作文档实现修饰的具体文件或目录（可选）。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　Y0`-o r#V r n ~"p9f5N rar常用命令主要有:&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　1) a 添加文件到操作文档 举例rar a test.rar file1.txt&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　若test.rar文件不存在，则打包file1.txt文件成test.rar rar a test.rar file2.txt 若test.rar文件已经存在，则添加file2.txt文件到test.rar中(这样 test.rar中就有两个文件了）注，如果操作文档中已有某文件的一份拷贝，则a命令更新该文件 另，对目录也可以进行操作 eg. rar a test.rar dir1 。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　2) e test.rar 注，用e解压的话，不仅原来的file1.txt和file2.txt被解压到当前目录，就连dir1里面的所有文件也被解压到当前目录下，不能保持压缩前的目录结构，如果想保持压缩前的目录结构，用x解压。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　3) c 对操作文档添加说明注释 eg. rar c test.rar&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　（会出现Reading comment from stdin字样，然后输入一行或多行注释，以ctrl+d结束）。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　4) cf 添加文件注释，类似上面的c，不过这个是对压缩文档中每个文件进行注释 cw 将文档注释写入文件 eg. rar cw test.rar comment.txt。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　5) d 从文档中删除文件 eg. rar d test.rar file1.txt e&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　将文件解压到当前目录 eg. rar。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　6) e test.rar 注，用e解压的话，不仅原来的file1.txt和file2.txt被解压到当前目录，就连dir1里面的所有文件也被解压到当前目录下，不能保持压缩前的目录结构，如果想保持压缩前的目录结构，用x解压。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　7) r 修复文档 eg. rar r test.rar&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　当rar文件有问题时，可以尝试用该命令进行修复（鬼知道有多少用） 。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　8) s 转换文档成自解压文档 eg. rar s test.rar&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　会生成一个test.sfx的可执行文档，运行它的效果就相当于rar x test.rar， 适合于向没有rar的用户传输文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　9) t 检测文档 eg. rar t test.rar&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　检测test.rar的完整性。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　10) k 锁定文档 eg. rar k test.rar&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />　　锁定文档后，该文档就无法进行任何更新操作了。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.Z文件：&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />命令： compress&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />格式： compress 选项 文件列表&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />功能： 用Lempel-ziv压缩方法来压缩文件或压缩标准输入&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />选项： -r 递归操作，如果指定目录变元，则压缩该目录及其子目录中的所有文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-c 将压缩数据返回标准输出，而缺省情况下为压缩文件时将压缩数据返回文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-v 显示每个文件夹的压缩百分比。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解释： 在用compress压缩文件时，将在原文件名之后加上扩展名.Z。如果不指定文件，则压缩标准输入，其结果返回标准输出。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />实例： 目的：压缩/mnt/lgx/a1.doc文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />命令：＃compress /mnt/lgx/a1.doc&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />结果：压缩后生成a1.doc.Z文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />命令： uncompress&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />格式： uncompress 选项 文件列表&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />功能： 解压缩用compress 程序压缩过的文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />选项： -c 它将压缩数据发往标准输出而不是改写旧的压缩文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解释： 如果不指定文件，则解压缩标准输入。缺省-c时，为解压缩。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />实例： 目的：解压缩/mnt/lgx/a1.doc.Z&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />命令：# uncompress /mnt/lgx/a1.doc.Z&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.gz文件：&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />命令： gzip&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />格式： gzip 选项 文件目录列表&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />功能： 用Lempel-ziv编码压缩文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />选项： -c 压缩结果写入标准输出，原文件保持不变。缺省时gzip将原文件压缩为.gz文件，并删除原文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-v 输出处理信息。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-d 解压缩指定文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-t 测试压缩文件的完整性。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />解释： 值得一提的是，gzip比compress压缩更加有效。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />实例： 目的：压缩/mnt/lgx/a1.doc&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />命令：＃gzip -v /mnt/lgx/a1.doc&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />结果：产生a1.doc.gz的压缩文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />命令： gunzip&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />格式： gunzip 选项 文件列表&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />功能： 解压缩用gzip命令（以及compress和zip命令）压缩过的文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />选项： -c 将输出写入标准输出，原文件保持不变。缺省时，gunzip将压缩文件变成解压缩文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-l 列出压缩文件中的文件而不解压缩。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-r 递归解压缩，深入目录结构中，解压缩命令行变元所指定目录中的所有子目录内的文件。&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />实例： 目的：解压缩/mnt/lgx/a1.doc.gz&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />命令：＃gunzip /mnt/lgx/a1.doc.gz&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />.tar文件：&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" /><br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />命令： tar&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />格式： tar 选项 文件目录列表&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />功能： 对文件目录进行打包备份&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />选项： -c 建立新的归档文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-r 向归档文件末尾追加文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-x 从归档文件中解出文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-O 将文件解开到标准输出&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-v 处理过程中输出相关信息&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-f 对普通文件操作&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-z 调用gzip来压缩归档文件，与-x联用时调用gzip完成解压缩&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />-Z 调用compress来压缩归档文件，与-x联用时调用compress完成解压缩&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />实例1： 目的：用tar打包一个目录下的文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />命令：＃tar -cvf /mnt/lgx/a1.doc&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />结果：产生一个以.tar为扩展名的打包文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />实例2： 目的：用tar解开打包文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />命令：＃tar -xvf /mnt/lgx/a1.doc.tar&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />附加说明：在通常情况下，tar打包与gzip（压缩）经常联合使用，效果更好。方法是：&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />首先用tar打包，如：＃tar -cvf /mnt/lgx/a1.doc （产生a1.doc.tar文件）&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />然后用gzip压缩a1.doc.tar文件，如：＃gzip /mnt/lgx/a1.doc.tar （产生a1.doc.tar.gz文件）&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />实例3： 目的：解压a1.doc.tar.gz文件&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />方法1：&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />＃gzip -dc /mnt/lgx/a1.doc.tar.gz （产生a1.doc.tar文件）&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />＃tar -xvf /mnt/lgx/a1.doc.tar （产生a1.doc文件）&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />这两次命令也可使用管道功能，把两个命令合二为一：&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />＃gzip -dc /mnt/lgx/a1.doc.tar.gz | tar -xvf&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />方法2：使用tar提供的自动调用gzip解压缩功能&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />＃tar -xzvf /mnt/lgx/a1.doc.tar.gz&nbsp;<br style="color: #0000ff; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.2000007629395px; background-color: #ffffff;" />经过tar打包后，也可用compress命令压缩（注：gzip比compress压缩更加有效），产生一个以.tar.Z的文件，在解包时，可先用 &#8220;uncompress 文件名&#8221;格式解压，然后用&#8220;tar -xvf 文件名&#8221;解包。也可直接调用&#8220;tar -Zxvf 文件名&#8221;解包。<br /><br />转自:http://bjxuguoli.iteye.com/blog/761964<br /><br /><img src ="http://www.cppblog.com/abilitytao/aggbug/208849.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/abilitytao/" target="_blank">abilitytao</a> 2014-11-11 23:34 <a href="http://www.cppblog.com/abilitytao/archive/2014/11/11/208849.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Windows上转unix目录</title><link>http://www.cppblog.com/abilitytao/archive/2014/10/24/208668.html</link><dc:creator>abilitytao</dc:creator><author>abilitytao</author><pubDate>Fri, 24 Oct 2014 09:28:00 GMT</pubDate><guid>http://www.cppblog.com/abilitytao/archive/2014/10/24/208668.html</guid><wfw:comment>http://www.cppblog.com/abilitytao/comments/208668.html</wfw:comment><comments>http://www.cppblog.com/abilitytao/archive/2014/10/24/208668.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/abilitytao/comments/commentRss/208668.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/abilitytao/services/trackbacks/208668.html</trackback:ping><description><![CDATA[pushd <a href="file://\\msad\root\ap\apbo\ku\USERS\weitaol\Desktop">\\msad\root\ap\apbo\ku\USERS\weitaol\Desktop</a> <br /><br />运行命令<br />V:\AP\APBO\KU\USERS\weitaol\Desktop\TAP\Course\System Architecture\SOAP &amp; REST A<br />ssessment\mybank&gt;xjc -b .\src\binding.xml -d&nbsp; .\src\ -p src.java.mybank.soap.generated .\src\src\xml\SOAPRequestResponse.xsd<img src ="http://www.cppblog.com/abilitytao/aggbug/208668.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/abilitytao/" target="_blank">abilitytao</a> 2014-10-24 17:28 <a href="http://www.cppblog.com/abilitytao/archive/2014/10/24/208668.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>数据库练习</title><link>http://www.cppblog.com/abilitytao/archive/2014/10/15/208582.html</link><dc:creator>abilitytao</dc:creator><author>abilitytao</author><pubDate>Wed, 15 Oct 2014 15:39:00 GMT</pubDate><guid>http://www.cppblog.com/abilitytao/archive/2014/10/15/208582.html</guid><wfw:comment>http://www.cppblog.com/abilitytao/comments/208582.html</wfw:comment><comments>http://www.cppblog.com/abilitytao/archive/2014/10/15/208582.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/abilitytao/comments/commentRss/208582.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/abilitytao/services/trackbacks/208582.html</trackback:ping><description><![CDATA[计算两日期间隔天数<br />values (days(current date) - days('2014-09-01'))<br /><br />去出某一字符串的的一个单词，空格为分隔符<br />select substr(title,1,instr(title,' ')-1) from titles<br /><br />将字符串的一个空格替换为'--hello--'<br />select substr(title,1,locate(' ',title)-1)&nbsp; || '--hello--' ||&nbsp; substr(title,locate(' ',title)+1) from titles<br /><br />db2生成随机数<br />select case when price is null then INT(rand()*100) else price end from titles<br /><br />两日期相差多少月，64代表月。参数可以更改求出周，小时等等。<br />select TIMESTAMPDIFF(64,char(TIMESTAMP(CURRENT DATE) - TIMESTAMP(pubdate)) )from titles<br /><br />有关db2日期操作可参考此博客。<br /><a href="http://www.cnblogs.com/wanghonghu/archive/2012/05/25/2518604.html">http://www.cnblogs.com/wanghonghu/archive/2012/05/25/2518604.html</a> <br /><br />建立数据表，有generated always列<br />create table t1<br />(<br />c1 char(30),<br />c2 double,<br />c3 int not null generated always as identity<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (start with 100, increment by 5)<br />)<br />第一次更新用insert into t1(c1,c2,c3) values('123',34,default)<br />以后用 insert into t1(c1,c2) values('hi',45)<br /><br />如果是generated by default<br />create table t1<br />(<br />c1 char(30),<br />c2 double,<br />c3 int not null generated by default as identity<br />(start with 100, increment by 5)<br />)<br />如果插入时只有两个参数，就按默认的来<br />如果三个参数，就是插入的那个数<br />默认生成的第三个数可以修改，系统会有记录，即使修改了也会从上一次的默认位置开始叠加。不会再回到100.<br /><br /><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from authors</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select au_lname, au_fname from authors where state ='CA'</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from publishers</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select distinct state from publishers</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select *from titles</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from titles where price is null</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">-- select case when price is null then 0 else price end from titles-- it works!!!!!!!!!!</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">-- 4 Functions </p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select varchar_format(current date - date('2011-01-01') + date, 'DD-MM-YY') as newDate,</p>
<p align="left">-- varchar_format(date,'DD-MM-YY') as olddate from sales</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--values current date - date('2014-01-01') + date('2014-01-02') </p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select *from roysched</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select hex(lorange) from roysched</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from titles where price in (20,19) -- in one shot ZANZANZANZANZAN!!!</p></font></font><font size="2">
<p align="left"></p></font><font color="#800000" size="2"><font color="#800000" size="2">
<p>select</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">case</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">type</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">when</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">'business'</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">then</font></font><font size="2"> Title </font><font color="#800000" size="2"><font color="#800000" size="2">else</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">'other'</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">end</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">from</font></font><font size="2"> titles 联系条件语句并显示成不同的属性</p></font>-----------------------------------------------------------------------------------------------<br /><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from authors</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select au_lname, au_fname from authors where state ='CA'</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from publishers</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select distinct state from publishers</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select *from titles</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from titles where price is null</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">-- select case when price is null then 0 else price end from titles-- it works!!!!!!!!!!</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">-- 4 Functions </p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select varchar_format(current date - date('2011-01-01') + date, 'DD-MM-YY') as newDate,</p>
<p align="left">-- varchar_format(date,'DD-MM-YY') as olddate from sales</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--values current date - date('2014-01-01') + date('2014-01-02') </p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select *from roysched</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select hex(lorange) from roysched</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from titles where price in (20,19) -- in one shot ZANZANZANZANZAN!!!</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select case type when 'business' then Title else 'other' end from titles</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select syscolumns.length from syscolumns where syscolumns.id = 'titles' and syscolumns.name = 'title'</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--5 Grouping </p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select (days(max(pubdate)) - days(min(pubdate)) )/365 from titles</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select title from titles order by length(title)</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select *from titles</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select count(*) from authors group by city</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select title from titles where length(title) = (select max(length(title)) from titles)</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select coalesce(price,0) from titles -- yuan lai bushi yong is null shi yong zhe ge a!!!!</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select length(price) from titles </p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">/*</p>
<p align="left">select title from titles where length(title) &gt;= all</p>
<p align="left">(</p>
<p align="left">select length(title) from titles </p>
<p align="left">)</p>
<p align="left">*/</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select pubdate from titles</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">/*</p>
<p align="left">select title,pubdate from titles where pubdate &gt;= all</p>
<p align="left">(</p>
<p align="left">select pubdate from titles</p>
<p align="left">)</p>
<p align="left">*/</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select count(*) from sales group by stor_num</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from sales</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from publishers</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from titles as a inner join publishers as b on a.pub_id = b.pub_id</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select title,city,a.pub_id from titles as a inner join publishers as b on a.pub_id = b.pub_id where city not in ('Boston')</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from psales</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">/*</p>
<p align="left">select b.ord_num,b.discount,d.discounttype from psales as a inner join salesdetail as b on a.stor_id = b. stor_id and a.ord_num = b.ord_num</p>
<p align="left">inner join stores as c on a.stor_id = c.stor_id inner join discounts as d on c.stor_id = d.stor_id order by b.ord_num</p>
<p align="left">*/</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from authors</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from publishers</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from authors as a inner join publishers as b on a.city = b.city</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select sum(qty) from salesdetail</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select pub_name, count(distinct type) from publishers as a inner join titles as b on a.pub_id = b.pub_id group by pub_name</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select *from titleauthor</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--7 Sub-Queries</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">/*</p>
<p align="left">select pub_name from publishers where pub_id in </p>
<p align="left">(</p>
<p align="left">select pub_id from titles</p>
<p align="left">) </p>
<p align="left">*/</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from publishers</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--nice !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</p>
<p align="left">/*</p>
<p align="left">select type,title,t1.price</p>
<p align="left">from titles as t1</p>
<p align="left">where price &gt; (select avg(price) from titles as t2 where t2.type = t1.type)</p>
<p align="left">*/</p>
<p align="left">-- nice !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</p></font></font><font size="2">
<p align="left"></p>
<p align="left">　</p></font><font color="#800000" size="2"><font color="#800000" size="2">
<p align="left">select</font></font><font size="2"> title,t1.price</p></font><font color="#800000" size="2"><font color="#800000" size="2">
<p align="left">from</font></font><font size="2"> titles </font><font color="#800000" size="2"><font color="#800000" size="2">as</font></font><font size="2"> t1</p></font><font color="#800000" size="2"><font color="#800000" size="2">
<p align="left">where</font></font><font size="2"> price &gt; </font><font color="#800000" size="2"><font color="#800000" size="2">all</font></font><font size="2">(</font><font color="#800000" size="2"><font color="#800000" size="2">select</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">coalesce</font></font><font size="2">(price,0) </font><font color="#800000" size="2"><font color="#800000" size="2">from</font></font><font size="2"> titles </font><font color="#800000" size="2"><font color="#800000" size="2">as</font></font><font size="2"> t2 </font><font color="#800000" size="2"><font color="#800000" size="2">where</font></font><font size="2"> t2.</font><font color="#800000" size="2"><font color="#800000" size="2">type</font></font><font size="2"> != t1.</font><font color="#800000" size="2"><font color="#800000" size="2">type</font></font><font size="2">)</p>
<p align="left"></p>
<p align="left">　</p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from titles</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select t1.type,t1.title,t1.price,(select avg(price) from titles as t2 where t2.type = t1.type)</p>
<p align="left">--from titles as t1</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--where price &gt; (select avg(price) from titles as t2 where t2.type = t1.type)</p></font></font><font size="2">
<p align="left"></p>
<p align="left">　</p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select avg(price) from titles</p>
<p align="left">--select abs(13.93750000000000000000000000- price) from titles</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p>--select coalesce(abs((select avg(price) from titles) - price),0) from titles</p></font></font><br /><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2"> 
<p align="left">--select count(*) as ANS from SB_AUCTION where (days(enddate) - days(startdate) &lt; 10)</p></font></font><font size="2">
<p align="left"></p>
<p align="left">/*</p></font><font color="#800000" size="2"><font color="#800000" size="2">
<p align="left">select</font></font><font size="2"> description, enddate, reserve </font><font color="#800000" size="2"><font color="#800000" size="2">from</font></font><font size="2"> SB_Auction </font><font color="#800000" size="2"><font color="#800000" size="2">inner</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">join</font></font><font size="2"> sb_item </font><font color="#800000" size="2"><font color="#800000" size="2">on</font></font><font size="2"> SB_Auction.itemid = sb_item.itemid </p>
<p align="left"></font><font color="#800000" size="2"><font color="#800000" size="2">where</font></font><font size="2"> (</font><font color="#800000" size="2"><font color="#800000" size="2">date</font></font><font size="2">(</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">'2011-02-20'</font></font><font size="2">) &gt;= startdate </font><font color="#800000" size="2"><font color="#800000" size="2">and</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">date</font></font><font size="2">(</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">'2011-02-20'</font></font><font size="2">) &lt;= enddate) </font><font color="#800000" size="2"><font color="#800000" size="2">order</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">by</font></font><font size="2"> reserve </font><font color="#800000" size="2"><font color="#800000" size="2">desc</p></font></font><font size="2">
<p align="left">*/</p>
<p align="left"></p>
<p align="left">　</p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from sb_bid</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select name from (sb_bid as a inner join sb_auction as b on a.bidder = b.userid) inner join sb_user as c on b.userid = c.userid group by name</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from authors</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select newA.name from</p>
<p align="left">--(</p>
<p align="left">--select name,c.itemid from (sb_user as a inner join sb_auction as b on a.userid = b.userid)</p>
<p align="left">-- inner join sb_item as c on b.itemid = c.itemid </p>
<p align="left">--) AS newA</p></font></font><font size="2">
<p align="left"></p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from sb_auction</p></font></font><font size="2">
<p align="left">/*</p></font><font color="#800000" size="2"><font color="#800000" size="2">
<p align="left">create</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">view</font></font><font size="2"> weitaol_view</p></font><font color="#800000" size="2"><font color="#800000" size="2">
<p align="left">as</p>
<p align="left">select</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">c</font></font><font size="2">.auctionid, </font><font color="#800000" size="2"><font color="#800000" size="2">max</font></font><font size="2">(amount) </font><font color="#800000" size="2"><font color="#800000" size="2">as</font></font><font size="2"> winning_bid </font><font color="#800000" size="2"><font color="#800000" size="2">from</font></font><font size="2"> sb_auction </font><font color="#800000" size="2"><font color="#800000" size="2">as</font></font><font size="2"> a </font><font color="#800000" size="2"><font color="#800000" size="2">inner</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">join</font></font><font size="2"> sb_user </font><font color="#800000" size="2"><font color="#800000" size="2">as</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">b</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">on</font></font><font size="2"> a.winnerid = </font><font color="#800000" size="2"><font color="#800000" size="2">b</font></font><font size="2">.</font><font color="#800000" size="2"><font color="#800000" size="2">userid</font></font><font size="2"> </p>
<p align="left"></font><font color="#800000" size="2"><font color="#800000" size="2">inner</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">join</font></font><font size="2"> sb_bid </font><font color="#800000" size="2"><font color="#800000" size="2">as</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">c</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">on</font></font><font size="2"> a.auctionid = </font><font color="#800000" size="2"><font color="#800000" size="2">c</font></font><font size="2">.auctionid </font><font color="#800000" size="2"><font color="#800000" size="2">where</font></font><font size="2"> a.</font><font color="#800000" size="2"><font color="#800000" size="2">state</font></font><font size="2"> = </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">'sold'</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">group</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">by</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">c</font></font><font size="2">.auctionid </p>
<p align="left">*/</p></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">
<p align="left">--select * from weitaol_view</p></font></font><font size="2">
<p align="left"></p>
<p align="left">　</p></font><font color="#800000" size="2"><font color="#800000" size="2">
<p align="left">select</font></font><font size="2"> enddate, description,</font><font color="#800000" size="2"><font color="#800000" size="2">coalesce</font></font><font size="2">(</font><font color="#800000" size="2"><font color="#800000" size="2">name</font></font><font size="2">,</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">'=='</font></font><font size="2">) </font><font color="#800000" size="2"><font color="#800000" size="2">as</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">name</font></font><font size="2"> ,</font><font color="#800000" size="2"><font color="#800000" size="2">coalesce</font></font><font size="2">(</font><font color="#800000" size="2"><font color="#800000" size="2">c</font></font><font size="2">.winning_bid,0) </font><font color="#800000" size="2"><font color="#800000" size="2">as</font></font><font size="2"> winning_bid </p>
<p align="left"></font><font color="#800000" size="2"><font color="#800000" size="2">from</font></font><font size="2"> sb_auction </font><font color="#800000" size="2"><font color="#800000" size="2">as</font></font><font size="2"> a </font><font color="#800000" size="2"><font color="#800000" size="2">inner</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">join</font></font><font size="2"> sb_item </font><font color="#800000" size="2"><font color="#800000" size="2">as</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">b</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">on</font></font><font size="2"> a.itemid = </font><font color="#800000" size="2"><font color="#800000" size="2">b</font></font><font size="2">.itemid </p>
<p align="left"></font><font color="#800000" size="2"><font color="#800000" size="2">left</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">join</font></font><font size="2"> sb_user </font><font color="#800000" size="2"><font color="#800000" size="2">on</font></font><font size="2"> a.winnerid = sb_user.</font><font color="#800000" size="2"><font color="#800000" size="2">userid</font></font><font size="2"> </p>
<p align="left"></font><font color="#800000" size="2"><font color="#800000" size="2">left</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">join</font></font><font size="2"> weitaol_view </font><font color="#800000" size="2"><font color="#800000" size="2">as</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">c</font></font><font size="2"> </font><font color="#800000" size="2"><font color="#800000" size="2">on</font></font><font size="2"> a.auctionid = </font><font color="#800000" size="2"><font color="#800000" size="2">c</font></font><font size="2">.auctionid</p>
<p align="left"></p>
<p align="left"></font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">/*</p>
<p align="left">select * from sb_auction</p>
<p>*/</p></font></font><br /><br /><br /><img src ="http://www.cppblog.com/abilitytao/aggbug/208582.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/abilitytao/" target="_blank">abilitytao</a> 2014-10-15 23:39 <a href="http://www.cppblog.com/abilitytao/archive/2014/10/15/208582.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Scala数组操作</title><link>http://www.cppblog.com/abilitytao/archive/2014/10/04/208489.html</link><dc:creator>abilitytao</dc:creator><author>abilitytao</author><pubDate>Sat, 04 Oct 2014 03:52:00 GMT</pubDate><guid>http://www.cppblog.com/abilitytao/archive/2014/10/04/208489.html</guid><wfw:comment>http://www.cppblog.com/abilitytao/comments/208489.html</wfw:comment><comments>http://www.cppblog.com/abilitytao/archive/2014/10/04/208489.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/abilitytao/comments/commentRss/208489.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/abilitytao/services/trackbacks/208489.html</trackback:ping><description><![CDATA[<div><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 />-->scala中的数组比java的数组强大很多&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;1、定长数组：长度不变的数组Array，如：声明一个长度为10的整形数组，val&nbsp;arr&nbsp;=&nbsp;Array[Int](10)；声明并初始化一个字符串数组：&nbsp;val&nbsp;arrStr&nbsp;=&nbsp;Array(&#8220;wo&#8221;,&#8221;cha&#8221;,&#8221;yo&#8221;)。访问数组方式:访问arrStr第一个元素，arrStr(1)即可<br />&nbsp;&nbsp;&nbsp;&nbsp;2、变长数组（即数组缓冲）：java中有ArrayList和scala中的ArrayBuffer等效；但是ArrayBuffer更加强大，通过下面的事列来熟悉ArrayBuffer：<br />import&nbsp;collection.mutable.ArrayBuffer<br />&nbsp;&nbsp;&nbsp;&nbsp;val&nbsp;arrbuff1&nbsp;=&nbsp;ArrayBuffer[Int]()<br />&nbsp;&nbsp;&nbsp;&nbsp;val&nbsp;arrBuff2&nbsp;=&nbsp;ArrayBuffer(1,3,4,-1,-4)<br />&nbsp;&nbsp;&nbsp;&nbsp;arrbuff1&nbsp;+=&nbsp;23&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">用+=在尾端添加元素</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;arrbuff1&nbsp;+=&nbsp;(2,3,4,32)&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">同时在尾端添加多个元素</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;arrbuff1&nbsp;++=&nbsp;arrBuff2&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">可以用&nbsp;++=操作符追加任何集合</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;arrbuff1&nbsp;++=&nbsp;Array(2,43,88,66)<br />&nbsp;&nbsp;&nbsp;&nbsp;arrbuff1.trimEnd(2)&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">移除最后的2个元素</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;arrbuff1.remove(2)&nbsp;&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">移除arr(2+1)个元素</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;arrbuff1.remove(2,4)&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">从第三个元素开始移除4个元素</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;val&nbsp;arr&nbsp;=&nbsp;arrbuff1.toArray&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">将数组缓冲转换为Array</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;val&nbsp;arrbuff2&nbsp;=&nbsp;arr.toBuffer&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">将Array转换为数组缓冲</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;3、遍历数组和数组缓冲：在java中数组和数组列表/向量上语法有些不同。scala则更加统一，通常情况，我们可以用相同的代码处理这两种数据结构，<span style="color: #0000FF; ">for</span>(&#8230;)&nbsp;yield&nbsp;循环创建一个类型和原集合类型相同的新集合。for循环中还可以带守卫：在for中用if来实现。<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">for</span>(i&nbsp;&lt;-&nbsp;0&nbsp;until&nbsp;arrbuff1.length)&nbsp;yield&nbsp;arrbuff1(i)&nbsp;*&nbsp;2&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">将得到ArrayBuffer(2,6,4,-2,-4)</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">for</span>(i&nbsp;&lt;-&nbsp;0&nbsp;until&nbsp;(arrbuff1.length,2))&nbsp;yield&nbsp;arrbuff1(i)&nbsp;*&nbsp;2&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">将得到ArrayBuffer(12,-4)</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">for</span>(elem&nbsp;&lt;-0&nbsp;arrbuff1)&nbsp;print(elem)&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">如果不需要使用下标，用这种方式最简单了</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">for</span>(i&nbsp;&lt;-&nbsp;arrbuff1&nbsp;<span style="color: #0000FF; ">if</span>&nbsp;arrbuff1&nbsp;&gt;&nbsp;0)&nbsp;print&nbsp;i&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">打印出arrbuff1中为整数的值</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;arrbuff1.filter(&nbsp;_&nbsp;&gt;&nbsp;0).map{&nbsp;2&nbsp;*&nbsp;_}&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">生成arrbuff1中的正数的两倍的新集合</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;arrbuff1.filter&nbsp;{_&nbsp;&gt;&nbsp;0}&nbsp;map&nbsp;{2&nbsp;*&nbsp;_}&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">另一种写法</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;4、常用算法：scala有很多便捷内建函数，如<br />&nbsp;&nbsp;&nbsp;&nbsp;arrbuff1.sum&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">对arrbuff1元素求和</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;Array("asd","sdf","ss").max&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">求最大元素</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;arrbuff1.sorted(_&nbsp;&lt;&nbsp;_)&nbsp;&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">将arrbuff1元素从小到大排序</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;arrbuff1.sorted(_&nbsp;&gt;&nbsp;_)&nbsp;&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">从大到小排序</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;util.Sorting.quickSort(Array)&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">针对数组排序，单不能对数组缓冲排序</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;val&nbsp;arr&nbsp;=&nbsp;Array(1,23,4,2,45)<br />&nbsp;&nbsp;&nbsp;&nbsp;arr.mkString(",")&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">指定分割符</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;arr.mkString("(",",",")")&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">指定前缀、分隔符、后缀</span><span style="color: #008000; "><br /></span>更多函数参见Scaladoc<br />&nbsp;&nbsp;&nbsp;&nbsp;5、多维数组：<br />val&nbsp;matrix&nbsp;=&nbsp;Array.ofDim[Int](5,4)&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">三行四列的二维数组</span><span style="color: #008000; "><br /></span>matrix(2)(3)&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">访问第二行、第三个元素</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;6、scala数组和java互操作：由于scala数组是用java数组实现的，所以可以在java和scala之间来回传递，引入scala.collectin.JavaConversion&nbsp;，可以在代码中使用scala缓冲，在调用java方法时，这些对象会被自动包装成java列表。反过来讲，引入scala.collection.asScalaBuffer时，当java方法返回java.util.List时，我们可以让它转换成一个Buffer<br /><br />转自：<span style="font-size: 14px;">http://www.kankanews.com/ICkengine/archives/128572.shtml</span></div></div><img src ="http://www.cppblog.com/abilitytao/aggbug/208489.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/abilitytao/" target="_blank">abilitytao</a> 2014-10-04 11:52 <a href="http://www.cppblog.com/abilitytao/archive/2014/10/04/208489.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C++ 泛型编程练习 Adaptor Functor &amp; Helper Function</title><link>http://www.cppblog.com/abilitytao/archive/2014/09/29/208457.html</link><dc:creator>abilitytao</dc:creator><author>abilitytao</author><pubDate>Mon, 29 Sep 2014 15:50:00 GMT</pubDate><guid>http://www.cppblog.com/abilitytao/archive/2014/09/29/208457.html</guid><wfw:comment>http://www.cppblog.com/abilitytao/comments/208457.html</wfw:comment><comments>http://www.cppblog.com/abilitytao/archive/2014/09/29/208457.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/abilitytao/comments/commentRss/208457.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/abilitytao/services/trackbacks/208457.html</trackback:ping><description><![CDATA[<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 />-->#include&lt;iostream&gt;<br /><span style="color: #0000FF; ">using</span>&nbsp;<span style="color: #0000FF; ">namespace</span>&nbsp;std;<br /><br />template&nbsp;&lt;<span style="color: #0000FF; ">class</span>&nbsp;OutputIterator,&nbsp;<span style="color: #0000FF; ">class</span>&nbsp;Iterator,&nbsp;<span style="color: #0000FF; ">class</span>&nbsp;predicate&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">void</span>&nbsp;copy(OutputIterator&nbsp;o,&nbsp;Iterator&nbsp;f,&nbsp;Iterator&nbsp;l,&nbsp;predicate&nbsp;p)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">while</span>(f!=l)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>(p(*f))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*o&nbsp;=&nbsp;*f;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;++f;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;++o;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">else</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;++f;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />template&nbsp;&lt;<span style="color: #0000FF; ">class</span>&nbsp;Predicate&gt;<br /><span style="color: #0000FF; ">class</span>&nbsp;negate<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;Predicate&nbsp;p;<br /><span style="color: #0000FF; ">public</span>&nbsp;:<br />&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;typename&nbsp;Predicate::value_type&nbsp;value_type;<br />&nbsp;&nbsp;&nbsp;&nbsp;negate(<span style="color: #0000FF; ">const</span>&nbsp;Predicate&nbsp;&amp;pred):p(pred){}<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">bool</span>&nbsp;<span style="color: #0000FF; ">operator</span>()(<span style="color: #0000FF; ">const</span>&nbsp;value_type&nbsp;v)<span style="color: #0000FF; ">const</span><br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;!p(v);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />};<br /><br />template&lt;<span style="color: #0000FF; ">class</span>&nbsp;Number&gt;<br /><span style="color: #0000FF; ">struct</span>&nbsp;smallerThanX<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;Number&nbsp;value_type;<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;x;<br />&nbsp;&nbsp;&nbsp;&nbsp;smallerThanX(<span style="color: #0000FF; ">int</span>&nbsp;x):x(x)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">bool</span>&nbsp;<span style="color: #0000FF; ">operator</span>()(<span style="color: #0000FF; ">const</span>&nbsp;Number&amp;&nbsp;n)&nbsp;<span style="color: #0000FF; ">const</span><br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;n&lt;&nbsp;<span style="color: #0000FF; ">this</span>-&gt;x;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />};<br /><br />template&nbsp;&lt;<span style="color: #0000FF; ">class</span>&nbsp;Predicate&gt;<br />inline&nbsp;negate&lt;Predicate&nbsp;&gt;&nbsp;NOT&nbsp;(<span style="color: #0000FF; ">const</span>&nbsp;Predicate&nbsp;&amp;p)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;negate&lt;Predicate&gt;(p);<br />}<br /><br /><br /><span style="color: #0000FF; ">int</span>&nbsp;main()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;a[]&nbsp;=&nbsp;{1,2,3,4,5,6,7,8};<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;*b&nbsp;=&nbsp;<span style="color: #0000FF; ">new</span>&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;[10];&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;copy(b,a,a+8,NOT(smallerThanX&lt;<span style="color: #0000FF; ">int</span>&gt;(5)));<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;0;<br />}<br /><br />这种方式实在是有点难看啊。。。 代码不仔细看还看不懂，不知道为什么要这样写呢。。。</div><img src ="http://www.cppblog.com/abilitytao/aggbug/208457.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/abilitytao/" target="_blank">abilitytao</a> 2014-09-29 23:50 <a href="http://www.cppblog.com/abilitytao/archive/2014/09/29/208457.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C# Dictionary容器练习</title><link>http://www.cppblog.com/abilitytao/archive/2014/09/22/208377.html</link><dc:creator>abilitytao</dc:creator><author>abilitytao</author><pubDate>Mon, 22 Sep 2014 11:06:00 GMT</pubDate><guid>http://www.cppblog.com/abilitytao/archive/2014/09/22/208377.html</guid><wfw:comment>http://www.cppblog.com/abilitytao/comments/208377.html</wfw:comment><comments>http://www.cppblog.com/abilitytao/archive/2014/09/22/208377.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/abilitytao/comments/commentRss/208377.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/abilitytao/services/trackbacks/208377.html</trackback:ping><description><![CDATA[<font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"> 
</font></font></font><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; ">using</span>&nbsp;System;<br /><span style="color: #0000FF; ">using</span>&nbsp;System.Collections.Generic;<br /><span style="color: #0000FF; ">using</span>&nbsp;System.Linq;<br /><span style="color: #0000FF; ">using</span>&nbsp;System.Text;<br /><br /><span style="color: #0000FF; ">class</span>&nbsp;MagicDictionary<br />{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">private</span>&nbsp;Dictionary&lt;String,&nbsp;String&gt;&nbsp;dic;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">public</span>&nbsp;MagicDictionary()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dic&nbsp;=&nbsp;<span style="color: #0000FF; ">new</span>&nbsp;Dictionary&lt;<span style="color: #0000FF; ">string</span>,&nbsp;<span style="color: #0000FF; ">string</span>&gt;();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">void</span>&nbsp;Add(String&nbsp;key,&nbsp;String&nbsp;value)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>&nbsp;(dic.ContainsKey(key)&amp;&amp;dic[key]==value)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">throw</span>&nbsp;<span style="color: #0000FF; ">new</span>&nbsp;Exception("KeyValuePair&nbsp;already&nbsp;exsits");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dic.Add(key,&nbsp;value);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">void</span>&nbsp;Remove(String&nbsp;key)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>&nbsp;(!dic.ContainsKey(key))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">throw</span>&nbsp;<span style="color: #0000FF; ">new</span>&nbsp;Exception("it&nbsp;doesn't&nbsp;exsit");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dic.Remove(key);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">void</span>&nbsp;Set(String&nbsp;key,&nbsp;String&nbsp;value)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>&nbsp;(dic.ContainsKey(key))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dic[key]&nbsp;=&nbsp;value;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">else</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dic.Add(key,&nbsp;value);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;Get(String&nbsp;key)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;dic[key];<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">void</span>&nbsp;PrintAll()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">foreach</span>&nbsp;(KeyValuePair&lt;String,&nbsp;String&gt;&nbsp;i&nbsp;<span style="color: #0000FF; ">in</span>&nbsp;dic)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(i.Key&nbsp;+&nbsp;"&nbsp;"&nbsp;+&nbsp;i.Value);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;TryGetValue(String&nbsp;key)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>&nbsp;(dic.ContainsKey(key))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;dic[key];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">else</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;"";<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">public</span>&nbsp;String&nbsp;<span style="color: #0000FF; ">this</span>[String&nbsp;key]<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">set</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dic[key]&nbsp;=&nbsp;value;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">get</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;dic[key];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">public</span>&nbsp;<span style="color: #0000FF; ">static</span>&nbsp;<span style="color: #0000FF; ">void</span>&nbsp;Main()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">try</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MagicDictionary&nbsp;t&nbsp;=&nbsp;<span style="color: #0000FF; ">new</span>&nbsp;MagicDictionary();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.Add("Hi",&nbsp;"Hello");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">&nbsp;&nbsp;t.Add("Hi",&nbsp;"Hello");</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.Add("What",&nbsp;"ever");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.Add("Pretty",&nbsp;"Girl");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.Add("Apple",&nbsp;"Google");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.PrintAll();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.Remove("Pretty");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.Remove("#$@#*$");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.Set("What",&nbsp;"Whatever");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>&nbsp;(t.TryGetValue("Hi")&nbsp;!=&nbsp;"")<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine("OK");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">else</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine("Bu&nbsp;OK");<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>&nbsp;(t.TryGetValue("Appoe")&nbsp;!=&nbsp;"")<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine("OK");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">else</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine("Bu&nbsp;OK");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(t.Get("Apple"));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t["Apple"]&nbsp;=&nbsp;"BIG&nbsp;GOOGLE";<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.PrintAll();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">catch</span>&nbsp;(System.Exception&nbsp;ex)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(ex.Message);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(ex.Message);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />}</div><img src ="http://www.cppblog.com/abilitytao/aggbug/208377.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/abilitytao/" target="_blank">abilitytao</a> 2014-09-22 19:06 <a href="http://www.cppblog.com/abilitytao/archive/2014/09/22/208377.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C# 猜数字小游戏(IDisposable接口练习)</title><link>http://www.cppblog.com/abilitytao/archive/2014/09/21/208368.html</link><dc:creator>abilitytao</dc:creator><author>abilitytao</author><pubDate>Sun, 21 Sep 2014 04:26:00 GMT</pubDate><guid>http://www.cppblog.com/abilitytao/archive/2014/09/21/208368.html</guid><wfw:comment>http://www.cppblog.com/abilitytao/comments/208368.html</wfw:comment><comments>http://www.cppblog.com/abilitytao/archive/2014/09/21/208368.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/abilitytao/comments/commentRss/208368.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/abilitytao/services/trackbacks/208368.html</trackback:ping><description><![CDATA[<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; ">using</span>&nbsp;System;<br /><span style="color: #0000FF; ">using</span>&nbsp;System.Collections.Generic;<br /><span style="color: #0000FF; ">using</span>&nbsp;System.Linq;<br /><span style="color: #0000FF; ">using</span>&nbsp;System.Text;<br /><br /><span style="color: #0000FF; ">class</span>&nbsp;iTimer:IDisposable<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;mes;<br />&nbsp;&nbsp;&nbsp;&nbsp;DateTime&nbsp;s;<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">public</span>&nbsp;iTimer(String&nbsp;mes)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">this</span>.mes&nbsp;=&nbsp;mes;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;=&nbsp;DateTime.Now;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">public</span>&nbsp;<span style="color: #0000FF; ">void</span>&nbsp;Dispose()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DateTime&nbsp;t&nbsp;=&nbsp;DateTime.Now;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TimeSpan&nbsp;ts&nbsp;=&nbsp;t&nbsp;-&nbsp;s;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.Error.WriteLine("spent&nbsp;time(in&nbsp;Milliseconds):");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.Error.WriteLine(ts.TotalMilliseconds);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">public</span>&nbsp;<span style="color: #0000FF; ">static</span>&nbsp;<span style="color: #0000FF; ">void</span>&nbsp;Main()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">using</span>&nbsp;(iTimer&nbsp;t&nbsp;=&nbsp;<span style="color: #0000FF; ">new</span>&nbsp;iTimer("game"))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;ans&nbsp;=&nbsp;10;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;input&nbsp;=&nbsp;Int32.Parse(Console.ReadLine());<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">while</span>(ans!=input)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine("please&nbsp;try&nbsp;again.");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input&nbsp;=&nbsp;Int32.Parse(Console.ReadLine());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine("Correct!");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.Error.WriteLine("the&nbsp;program&nbsp;is&nbsp;terminated");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br /><br />}</div><img src ="http://www.cppblog.com/abilitytao/aggbug/208368.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/abilitytao/" target="_blank">abilitytao</a> 2014-09-21 12:26 <a href="http://www.cppblog.com/abilitytao/archive/2014/09/21/208368.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>