??xml version="1.0" encoding="utf-8" standalone="yes"?>国产韩国精品一区二区三区久久,99精品国产综合久久久久五月天,香蕉久久夜色精品升级完成http://m.shnenglu.com/Leon916/zh-cnWed, 07 May 2025 16:15:35 GMTWed, 07 May 2025 16:15:35 GMT60归ƈ排序http://m.shnenglu.com/Leon916/archive/2009/09/13/96034.htmlLeon916Leon916Sun, 13 Sep 2009 02:28:00 GMThttp://m.shnenglu.com/Leon916/archive/2009/09/13/96034.htmlhttp://m.shnenglu.com/Leon916/comments/96034.htmlhttp://m.shnenglu.com/Leon916/archive/2009/09/13/96034.html#Feedback0http://m.shnenglu.com/Leon916/comments/commentRss/96034.htmlhttp://m.shnenglu.com/Leon916/services/trackbacks/96034.html帖子Q是关于归ƈ排序的,发现错误很隐蔽(在我看来Q,后来l过调试和跟t才扑ֈ了这个错误。结果是一个很单的逻辑问题Q自己太W了Q花??个小时。哎Q还是看E序时粗枝大Ӟ

Leon916 2009-09-13 10:28 发表评论
]]>
STL源码阅读1http://m.shnenglu.com/Leon916/archive/2009/09/11/95969.htmlLeon916Leon916Fri, 11 Sep 2009 14:04:00 GMThttp://m.shnenglu.com/Leon916/archive/2009/09/11/95969.htmlhttp://m.shnenglu.com/Leon916/comments/95969.htmlhttp://m.shnenglu.com/Leon916/archive/2009/09/11/95969.html#Feedback0http://m.shnenglu.com/Leon916/comments/commentRss/95969.htmlhttp://m.shnenglu.com/Leon916/services/trackbacks/95969.html       单ȝ一下: 目前看到的技巧有Qtraite技术,仿函敎ͼ仿函数都是定义了()函数q算操作W的c?/span>Q。关于仿函数可以参看http://blog.csdn.net/kingofbirdzjy/archive/2007/12/10/1926653.aspx?

Leon916 2009-09-11 22:04 发表评论
]]>
重新开?/title><link>http://m.shnenglu.com/Leon916/archive/2009/09/11/95945.html</link><dc:creator>Leon916</dc:creator><author>Leon916</author><pubDate>Fri, 11 Sep 2009 09:08:00 GMT</pubDate><guid>http://m.shnenglu.com/Leon916/archive/2009/09/11/95945.html</guid><wfw:comment>http://m.shnenglu.com/Leon916/comments/95945.html</wfw:comment><comments>http://m.shnenglu.com/Leon916/archive/2009/09/11/95945.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/Leon916/comments/commentRss/95945.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/Leon916/services/trackbacks/95945.html</trackback:ping><description><![CDATA[       好长旉没有写程序了Q敲代码+调试׃?个小时时_׃ؓ了一道特单题目(acm3299Q,以后要多多锻炼才行?br> 代码如下Q? <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080"> 1</span><img src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 2</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">math.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 3</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080"> 4</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> E </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2.718281828</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080"> 5</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080"> 6</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> argc, </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">argv[])<br></span><span style="COLOR: #008080"> 7</span><span style="COLOR: #000000"><img id=Codehighlighter1_101_1004_Open_Image onclick="this.style.display='none'; Codehighlighter1_101_1004_Open_Text.style.display='none'; Codehighlighter1_101_1004_Closed_Image.style.display='inline'; Codehighlighter1_101_1004_Closed_Text.style.display='inline';" src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_101_1004_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_101_1004_Closed_Text.style.display='none'; Codehighlighter1_101_1004_Open_Image.style.display='inline'; Codehighlighter1_101_1004_Open_Text.style.display='inline';" src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_101_1004_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_101_1004_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080"> 8</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> t, d, h, e, hh;<br></span><span style="COLOR: #008080"> 9</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> index;<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> temp;<br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">( (scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%c</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">temp) </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">) </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> (temp </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">E</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">))<br></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img id=Codehighlighter1_204_991_Open_Image onclick="this.style.display='none'; Codehighlighter1_204_991_Open_Text.style.display='none'; Codehighlighter1_204_991_Closed_Image.style.display='inline'; Codehighlighter1_204_991_Closed_Text.style.display='inline';" src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_204_991_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_204_991_Closed_Text.style.display='none'; Codehighlighter1_204_991_Open_Image.style.display='inline'; Codehighlighter1_204_991_Open_Text.style.display='inline';" src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_204_991_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_204_991_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        index </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">( </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000"> ; i </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img id=Codehighlighter1_251_524_Open_Image onclick="this.style.display='none'; Codehighlighter1_251_524_Open_Text.style.display='none'; Codehighlighter1_251_524_Closed_Image.style.display='inline'; Codehighlighter1_251_524_Closed_Text.style.display='inline';" src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_251_524_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_251_524_Closed_Text.style.display='none'; Codehighlighter1_251_524_Open_Image.style.display='inline'; Codehighlighter1_251_524_Open_Text.style.display='inline';" src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </span><span id=Codehighlighter1_251_524_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_251_524_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            </span><span style="COLOR: #0000ff">switch</span><span style="COLOR: #000000">(temp)<br></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img id=Codehighlighter1_272_498_Open_Image onclick="this.style.display='none'; Codehighlighter1_272_498_Open_Text.style.display='none'; Codehighlighter1_272_498_Closed_Image.style.display='inline'; Codehighlighter1_272_498_Closed_Text.style.display='inline';" src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_272_498_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_272_498_Closed_Text.style.display='none'; Codehighlighter1_272_498_Open_Image.style.display='inline'; Codehighlighter1_272_498_Open_Text.style.display='inline';" src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>            </span><span id=Codehighlighter1_272_498_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_272_498_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            </span><span style="COLOR: #0000ff">case</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">T</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">:<br></span><span style="COLOR: #008080">20</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                index </span><span style="COLOR: #000000">|=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0x1</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%f</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">t);<br></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">23</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            </span><span style="COLOR: #0000ff">case</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">D</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">:<br></span><span style="COLOR: #008080">24</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                index </span><span style="COLOR: #000000">|=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0x2</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%f</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">d);<br></span><span style="COLOR: #008080">26</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">27</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            </span><span style="COLOR: #0000ff">case</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">H</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">:<br></span><span style="COLOR: #008080">28</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                index </span><span style="COLOR: #000000">|=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0x4</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">29</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%f</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">h);<br></span><span style="COLOR: #008080">30</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">31</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            </span><span style="COLOR: #0000ff">default</span><span style="COLOR: #000000">:<br></span><span style="COLOR: #008080">32</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">33</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">34</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>            }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">35</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%c</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">temp);<br></span><span style="COLOR: #008080">36</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">37</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">switch</span><span style="COLOR: #000000">(index)<br></span><span style="COLOR: #008080">38</span><span style="COLOR: #000000"><img id=Codehighlighter1_544_942_Open_Image onclick="this.style.display='none'; Codehighlighter1_544_942_Open_Text.style.display='none'; Codehighlighter1_544_942_Closed_Image.style.display='inline'; Codehighlighter1_544_942_Closed_Text.style.display='inline';" src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_544_942_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_544_942_Closed_Text.style.display='none'; Codehighlighter1_544_942_Open_Image.style.display='inline'; Codehighlighter1_544_942_Open_Text.style.display='inline';" src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </span><span id=Codehighlighter1_544_942_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_544_942_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">39</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            <br></span><span style="COLOR: #008080">40</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">case</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">:  </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> t d</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">41</span><span style="COLOR: #008000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">            e </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">6.11</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> exp(</span><span style="COLOR: #000000">5417.7530</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">((</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">273.16</span><span style="COLOR: #000000">) </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">(d</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">273.16</span><span style="COLOR: #000000">))));<br></span><span style="COLOR: #008080">42</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            hh </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">0.5555</span><span style="COLOR: #000000">) </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> (e </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">10.0</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">43</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            h </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> t </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> hh;<br></span><span style="COLOR: #008080">44</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">45</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">case</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">6</span><span style="COLOR: #000000">:        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">d, h ----t</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">46</span><span style="COLOR: #008000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">            e </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">6.11</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> exp(</span><span style="COLOR: #000000">5417.7530</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">((</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">273.16</span><span style="COLOR: #000000">) </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">(d</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">273.16</span><span style="COLOR: #000000">))));<br></span><span style="COLOR: #008080">47</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            t </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> h </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0.5555</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> (e </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">10.0</span><span style="COLOR: #000000">); <br></span><span style="COLOR: #008080">48</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">49</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">case</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">:            </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">t h ---d</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">50</span><span style="COLOR: #008000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">double</span><span style="COLOR: #000000"> e;<br></span><span style="COLOR: #008080">51</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            e </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (h</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">t)</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">0.5555</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">10.0</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">52</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            d </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">((</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">273.16</span><span style="COLOR: #000000">) </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> (log(e</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">6.11</span><span style="COLOR: #000000">))</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">5417.753</span><span style="COLOR: #000000">) </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">273.16</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">53</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">54</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">55</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">T %.1f D %.1f H %.1f\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, t, d, h);<br></span><span style="COLOR: #008080">56</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">57</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">58</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">59</span><span style="COLOR: #000000"><img src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span></div> <img src ="http://m.shnenglu.com/Leon916/aggbug/95945.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/Leon916/" target="_blank">Leon916</a> 2009-09-11 17:08 <a href="http://m.shnenglu.com/Leon916/archive/2009/09/11/95945.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C语言文gdhttp://m.shnenglu.com/Leon916/archive/2009/04/10/79456.htmlLeon916Leon916Fri, 10 Apr 2009 03:02:00 GMThttp://m.shnenglu.com/Leon916/archive/2009/04/10/79456.htmlhttp://m.shnenglu.com/Leon916/comments/79456.htmlhttp://m.shnenglu.com/Leon916/archive/2009/04/10/79456.html#Feedback1http://m.shnenglu.com/Leon916/comments/commentRss/79456.htmlhttp://m.shnenglu.com/Leon916/services/trackbacks/79456.html
int main(int argc, char *argv[])
{
    FILE 
*file;
    FILE 
*fw;
    
if( (file = fopen("main.cpp""r")) == NULL)
        
return -1;
    
if( (fw = fopen("text.txt""wt")) == NULL)
        
return -1;

    
char ch;
    
while( (ch=fgetc(file)) != EOF )
    {
        fputc(ch, fw);
        printf(
"%c", ch);
    }

    fclose(file);
    fclose(fw);
    
return 0;
}

    
//char ch[LEN] = {0};
    
//while( !feof(file) )
    
//{
    
//    fread(ch, sizeof(char), LEN-1, file);
    
//    printf("%s", ch);
    
//    fwrite(ch, sizeof(char), LEN-1, fw);
    
//    memset(ch, 0, sizeof(char)*LEN);
    
//}
q是用通过调用c语言的库文g来实现?br>以下是用C++的中的stream来实现的Q但是在处理中文的时候,会出C些ؕ码?br>
//fstream fs;
//    fs.open(_T("文本.txt"));
//
//    char arr[LEN] = {0};
//    wchar_t temp[2*LEN+1] = {0};
//    int length;
//    if(!fs)
//    {
//        cout << "Error" << endl;
//        return -1;
//    }
    
//while(!fs.eof())
    
//{
    
//    fs.read(arr, sizeof(arr)-1);
    
//    length = MultiByteToWideChar(CP_ACP, 0, arr, -1, NULL, NULL);
    
//    MultiByteToWideChar(CP_ACP, 0, arr, -1, temp, length);
    
//    wcout.imbue(locale("chs"));
    
//    wcout << temp;
    
//}
但是通过charcdq行d却不出现qQ感觉很奇怪?br>
int main(int argc, char *argv[])
{
    fstream fs;
    fs.open(_T(
"文本.txt"));

    fstream fw;
    fw.open(
"text.txt");
    
char arr[LEN] = {0};
    wchar_t temp[
2*LEN+1= {0};
    
int length;
    
if(!fs || !fw)
    {
        cout 
<< "Error" << endl;
        
return -1;
    }
    
while(!fs.eof())
    {
        fs.read(arr, 
sizeof(arr)-1);
        cout 
<< arr;
        fw.write(arr, 
sizeof(arr)-1);
        memset(arr, 
0sizeof(arr));

    }
    cout 
<< endl;
    fs.close();
    fw.close();
    
return 0;
}




Leon916 2009-04-10 11:02 发表评论
]]>
一个Java的B-Tree源代?/title><link>http://m.shnenglu.com/Leon916/archive/2009/03/29/78271.html</link><dc:creator>Leon916</dc:creator><author>Leon916</author><pubDate>Sun, 29 Mar 2009 07:54:00 GMT</pubDate><guid>http://m.shnenglu.com/Leon916/archive/2009/03/29/78271.html</guid><wfw:comment>http://m.shnenglu.com/Leon916/comments/78271.html</wfw:comment><comments>http://m.shnenglu.com/Leon916/archive/2009/03/29/78271.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://m.shnenglu.com/Leon916/comments/commentRss/78271.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/Leon916/services/trackbacks/78271.html</trackback:ping><description><![CDATA[    q是我在看一个Java开源Y件的时候,发现一个h写的代码Q里面有三个函数到现在还没有看懂Q先攑֜blog里面? <img src ="http://m.shnenglu.com/Leon916/aggbug/78271.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/Leon916/" target="_blank">Leon916</a> 2009-03-29 15:54 <a href="http://m.shnenglu.com/Leon916/archive/2009/03/29/78271.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>提醒http://m.shnenglu.com/Leon916/archive/2009/03/09/76032.htmlLeon916Leon916Mon, 09 Mar 2009 14:04:00 GMThttp://m.shnenglu.com/Leon916/archive/2009/03/09/76032.htmlhttp://m.shnenglu.com/Leon916/comments/76032.htmlhttp://m.shnenglu.com/Leon916/archive/2009/03/09/76032.html#Feedback0http://m.shnenglu.com/Leon916/comments/commentRss/76032.htmlhttp://m.shnenglu.com/Leon916/services/trackbacks/76032.html

Leon916 2009-03-09 22:04 发表评论
]]>
lcc阅读一http://m.shnenglu.com/Leon916/archive/2008/12/26/70401.htmlLeon916Leon916Fri, 26 Dec 2008 06:37:00 GMThttp://m.shnenglu.com/Leon916/archive/2008/12/26/70401.htmlhttp://m.shnenglu.com/Leon916/comments/70401.htmlhttp://m.shnenglu.com/Leon916/archive/2008/12/26/70401.html#Feedback0http://m.shnenglu.com/Leon916/comments/commentRss/70401.htmlhttp://m.shnenglu.com/Leon916/services/trackbacks/70401.html   最Ҏ的是W二章,是关于内存管理,到完之后感觉跟STL的内存管理有点相|都是把自q理分配的内存Q当需要的内存不够用的时候,在调用malloc重新甌?br>   对于后面几章Q还没有d理解Q还需要花一些时_边读代码边看书,一定要理解它是如何理W号、标识符和连接前端和后端的接口?br>
   鼓励一下自己,W一ơ读q么复杂的东西,但是q是成长的必׃路,加aQ?br>
ps:又要从头开始看了,有些东西q是不懂Q加油!Q!



Leon916 2008-12-26 14:37 发表评论
]]>
std:string学习http://m.shnenglu.com/Leon916/archive/2008/12/05/68694.htmlLeon916Leon916Fri, 05 Dec 2008 14:33:00 GMThttp://m.shnenglu.com/Leon916/archive/2008/12/05/68694.htmlhttp://m.shnenglu.com/Leon916/comments/68694.htmlhttp://m.shnenglu.com/Leon916/archive/2008/12/05/68694.html#Feedback3http://m.shnenglu.com/Leon916/comments/commentRss/68694.htmlhttp://m.shnenglu.com/Leon916/services/trackbacks/68694.html之所以抛弃char*的字W串而选用C++标准E序库中的stringc,是因Z和前者比较v来,不必担心内存是否_、字W串长度{等Q而且? Z个类出现Q他集成的操作函数以完成我们大多数情况?甚至?00%)的需要。我们可以用 = q行赋值操作,== q行比较Q? 做串联(是不是很?Q。我们尽可以把它看成是C++的基本数据类型?br>   好了Q进入正?#8230;……
首先Qؓ了在我们的程序中使用stringcdQ我们必d含头文g 。如下:
   #include //注意q里不是string.h string.h是C字符串头文g

1Q声明一个C++字符?br>声明一个字W串变量很简单:
   string Str;
q样我们声明了一个字W串变量Q但既然是一个类Q就有构造函数和析构函数。上面的声明没有传入参数Q所以就直接使用了string的默认的构造函敎ͼq个函数所作的是把Str初始化ؓ一个空字符丌ӀStringcȝ构造函数和析构函数如下Q?br>a)    string s;  //生成一个空字符串s
b)    string s(str) //拯构造函?生成str的复制品
c)    string s(str,stridx) //字W串str?#8220;始于位置stridx”的部分当作字W串的初?br>d)    string s(str,stridx,strlen) //字W串str?#8220;始于stridx且长度顶多strlen”的部分作为字W串的初?br>e)    string s(cstr) //C字符串作为s的初?br>f)    string s(chars,chars_len) //C字符串前chars_len个字W作为字W串s的初倹{?br>g)    string s(num,c) //生成一个字W串Q包含num个c字符
h)    string s(beg,end) //以区间beg;end(不包含end)内的字符作ؓ字符串s的初?br>i)    s.~string() //销毁所有字W,释放内存
都很单,我就不解释了?br>2Q字W串操作函数
   q里是C++字符串的重点Q我先把各种操作函数|列出来Q不喜欢把所有函数都看完的h可以在这里找自己喜欢的函敎ͼ再到后面看他的详l解释?br>a) =,assign()   //赋以新?br>b) swap()   //交换两个字符串的内容
c) +=,append(),push_back() //在尾部添加字W?br>d) insert() //插入字符
e) erase() //删除字符
f) clear() //删除全部字符
g) replace() //替换字符
h) + //串联字符?br>i) ==,!=,<,<=,>,>=,compare()  //比较字符?br>j) size(),length()  //q回字符数量
k) max_size() //q回字符的可能最大个?br>l) empty()  //判断字符串是否ؓI?br>m) capacity() //q回重新分配之前的字W容?br>n) reserve() //保留一定量内存以容U一定数量的字符
o) [ ], at() //存取单一字符
p) >>,getline() //从streamd某?br>q) <<  //谋值写入stream
r) copy() //某Dgؓ一个C_string
s) c_str() //内容以C_stringq回
t) data() //内容以字符数组形式q回
u) substr() //q回某个子字W串
v)查找函数
w)begin() end() //提供cMSTL的P代器支持
x) rbegin() rend() //逆向q代?br>y) get_allocator() //q回配置?br>下面详细介绍Q?br>2Q? C++字符串和C字符串的转换
   C++提供的由C++字符串得到对应的C_string的方法是使用data()、c_str()和copy()Q其中,data()以字W数l的形式 q回字符串内容,但ƈ不添?#8217;\0’。c_str()q回一个以‘\0’l尾的字W数l,而copy()则把字符串的内容复制或写入既有的 c_string或字W数l内。C++字符串ƈ不以’\0’l尾。我的徏议是在程序中能用C++字符串就使用Q除非万不得已不选用c_string。由 于只是简单介l,详细介绍掠过Q谁惌一步了解用中的注意事可以给我留a(到我的收件箱)。我详细解释?br>2Q? 大小和容量函?br>   一个C++字符串存在三U大:a)现有的字W数Q函数是size()和length()Q他们等效。Empty()用来查字W串是否为空? b)max_size() q个大小是指当前C++字符串最多能包含的字W数Q很可能和机器本w的限制或者字W串所在位|连l内存的大小有关pR我们一般情况下不用兛_他,应该大小 _我们用的。但是不够用的话Q会抛出length_error异常c)capacity()重新分配内存之前 string所能包含的最大字W数。这里另一个需要指出的是reserve()函数Q这个函Cؓstring重新分配内存。重新分配的大小由其参数军_Q? 默认参数?Q这时候会对stringq行非强制性羃减?br>
q有必要再重复一下C++字符串和C字符串{换的问题Q许多h会遇到这L? 题,自己做的E序要调用别人的函数、类什么的Q比如数据库q接函数Connect(char*,char*)Q,但别人的函数参数用的是char*形式 的,而我们知道,c_str()、data()q回的字W数l由该字W串拥有Q所以是一Uconst char*,要想作ؓ上面提及的函数的参数Q还必须拯C个char*,而我们的原则是能不用C字符串就不用。那么,q时候我们的处理方式是:如果 此函数对参数(也就是char*)的内容不修改的话Q我们可以这样Connect((char*)UserID.c_str(), (char*)PassWD.c_str()),但是q时候是存在危险的,因ؓq样转换后的字符串其实是可以修改的(有兴地可以自己试一试)Q所以我? 调除非函数调用的时候不对参数进行修改,否则必须拯C个char*上去。当Ӟ更稳妥的办法是无Z么情况都拯C个char*上去。同时我们也? L在仍然用C字符串进行编E的高手们(说他们是高手一点儿也不Q也许在我们q穿开裆裤的时候他们就开始编E了Q哈?#8230;Q写的函数都比较规范Q那? 我们׃必进行强制{换了?br>
2Q?元素存取
   我们可以使用下标操作W[]和函数at()对元素包含的字符q行讉K。但是应该注意的是操作符[]q不查烦引是否有效(有效索引 0~str.length()Q,如果索引失效Q会引v未定义的行ؓ。而at()会检查,如果使用at()的时候烦引无效,会抛? out_of_range异常?br>   有一个例外不得不_const string a;的操作符[]对烦引值是a.length()仍然有效Q其q回值是’\0’。其他的各种情况Qa.length()索引都是无效的。D例如下:
const string Cstr(“const string”);
string Str(“string”);

Str[3];    //ok
Str.at(3);  //ok

Str[100]; //未定义的行ؓ
Str.at(100);  //throw out_of_range

Str[Str.length()]  //未定义行?br>Cstr[Cstr.length()] //q回 ‘\0’
Str.at(Str.length());//throw out_of_range
Cstr.at(Cstr.length()) ////throw out_of_range

我不赞成cM于下面的引用或指针赋|
char& r=s[2];
char* p= &s[3];
因ؓ一旦发生重新分配,r,p立即失效。避免的Ҏ是不用?br>
2Q?比较函数
   C++字符串支持常见的比较操作W(>,>=,<,<=,==,!=Q,甚至支持string与C-string的比?? str<”hello”)。在使用>,>=,<,<=q些操作W的时候是Ҏ“当前字符Ҏ?#8221;字W按字典序q行逐一? 比较。字典排序靠前的字符,比较的顺序是从前向后比较Q遇C相等的字W就按这个位|上的两个字W的比较l果定两个字符串的大小。同 Ӟstring(“aaaa”)    另一个功能强大的比较函数是成员函数compare()。他支持多参数处理,支持用烦引值和长度定位子串来进行比较。他q回一个整数来表示比较l果Q返 回值意义如下:0-相等 ?-大于 <0-于。D例如下:
   string s(“abcd”);
   
   s.compare(“abcd”); //q回0
   s.compare(“dcba”); //q回一个小?的?br>   s.compare(“ab”); //q回大于0的?br>   
s.compare(s); //相等
   s.compare(0,2,s,2,2); //?#8221;ab”?#8221;cd”q行比较 于?br>   s.compare(1,2,”bcx”,2); //?#8221;bc”?#8221;bc”比较?br>怎么P功能够全的吧Q什么?q不能满你的胃口?好吧Q那{着Q后面有更个性化的比较算法。先l个提示Q用的是STL的比较算法。什么?对STL一H不通?靠,你重修吧Q?br>
2Q? 更改内容
q在字符串的操作中占了很大一部分?br>首先讲赋|W一个赋值方法当然是使用操作W?Q新值可以是string(如:s=ns) 、c_string(如:s=”gaint”)甚至单一字符Q如Qs=’j’Q。还可以使用成员函数assign()Q这个成员函数可以你更灉|的对字符串赋倹{还是D例说明吧Q?br>s.assign(str); //不说
s.assign(str,1,3);//如果str?#8221;iamangel” 是?#8221;ama”赋给字符?br>s.assign(str,2,string::npos);//把字W串str从烦引?开始到l尾赋给s
s.assign(“gaint”); //不说
s.assign(“nico”,5);//?#8217;n’ ‘I’ ‘c’ ‘o’ ‘\0’赋给字符?br>s.assign(5,’x’);//把五个x赋给字符?br>把字W串清空的方法有三个Qs=””;s.clear();s.erase();(我越来越觉得举例比说话让别hҎ懂!)?br>string提供了很多函数用于插入(insertQ、删除(eraseQ、替换(replaceQ、增加字W?br>先说增加字符Q这里说的增加是在尾巴上Q,函数?+=、append()、push_back()。D例如下:
s+=str;//加个字符?br>s+=”my name is jiayp”;//加个C字符?br>s+=’a’;//加个字符

s.append(str);
s.append(str,1,3);//不解释了 同前面的函数参数assign的解?br>s.append(str,2,string::npos)//不解释了

s.append(“my name is jiayp”);
s.append(“nico”,5);
s.append(5,’x’);

 

    字符串操作是一个不的主题,在标准C++?string字符串类成ؓ一个标?之所以抛弃char*的字W串而选用C++标准E序库中的stringc,是因Z和前者比较v来,不必担心内存是否_、字W串长度{等Q而且作ؓ一个类出现Q他集成的操作函数以完成我们大多数情况下的需?
    下面我们首先从一些示例开始学习下stringcȝ使用.
1)
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s("hehe");
    cout<<s<<endl;
    cin.get();
}
2)
#include <string>
#include <iostream>
using namespace std;

void main()
{
    char chs[] = "hehe";
    string s(chs);
    cout<<s<<endl;
    cin.get();
}
3)
#include <string>
#include <iostream>
using namespace std;

void main()
{
    char chs[] = "hehe";
    string s(chs,1,3);    //指定从chs的烦?开?最后复?个字?br>    cout<<s<<endl;
    cin.get();
}
4)
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s1("hehe");
    string s2(s1);   
    cout<<s2<<endl;
    cin.get();
}
5)
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s1("hehe",2,3);
    string s2(s1);   
    cout<<s2<<endl;
    cin.get();
}
6)
#include <string>
#include <iostream>
using namespace std;

void main()
{
    char chs[] = "hehe";
    string s(chs,3);    //chs?个字W作为初值构?br>    cout<<s<<endl;
    cin.get();
}
7)
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s(10,'k');    //分配10个字W?初值都?k'
    cout<<s<<endl;
    cin.get();
}
//以上是stringcd例的构造手D?都很?

9)
//赋新?br>#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s(10,'k');    //分配10个字W?初值都?k'
    cout<<s<<endl;
    s = "hehehehe";
    cout<<s<<endl;
    s.assign("kdje");
    cout<<s<<endl;
    s.assign("fkdhfkdfd",5);    //重新分配指定字符串的?的元素内?br>    cout<<s<<endl;       
    cin.get();
}
10)
//swapҎ交换
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s1 = "hehe";
    string s2 = "gagaga";
    cout<<"s1 : "<<s1<<endl;
    cout<<"s2 : "<<s2<<endl;
    s1.swap(s2);
    cout<<"s1 : "<<s1<<endl;
    cout<<"s2 : "<<s2<<endl;
    cin.get();
}
11)
//+=,append(),push_back()在尾部添加字W?br>#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s = "hehe";
    s += "gaga";
    cout<<s<<endl;
    s.append("嘿嘿");    //append()Ҏ可以d字符?br>    cout<<s<<endl;
    s.push_back('k');    //push_back()Ҏ只能d一个字W?..
    cout<<s<<endl;
    cin.get();
}
12)
//insert() 插入字符.其实,insertq用?与其他的插入操作是一L.
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s = "hehe";
    s.insert(0,"头部");            //在头部插?br>    s.insert(s.size(),"N");    //在尾部插?br>    s.insert(s.size()/2,"中间");//在中间插?br>    cout<<s<<endl;
    cin.get();
}
13)
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s = "abcdefg";
    s.erase(0,1);    //从烦?到烦?,卛_除掉?a'
    cout<<s<<endl;
    //其实,q可以用replaceҎ来执行删除操?br>    s.replace(2,3,"");//卛_指定范围内的字符替换?",卛_相删除了
    cout<<s<<endl;
    cin.get();
}

14)
//clear() 删除全部字符
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s = "abcdefg";
    cout<<s.length()<<endl;
    s.clear();
    cout<<s.length()<<endl;
    //使用earseҎ变相全删?br>    s = "dkjfd";
    cout<<s.length()<<endl;
    s.erase(0,s.length());
    cout<<s.length()<<endl;

    cin.get();
}
15)
//replace() 替换字符
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s = "abcdefg";
    s.replace(2,3,"!!!!!");//从烦?开?个字节的字符全替换成"!!!!!"
    cout<<s<<endl;
    cin.get();
}
16)
//==,!=,<,<=,>,>=,compare()  比较字符?br>#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s1 = "abcdefg";
    string s2 = "abcdefg";   
    if (s1==s2)cout<<"s1 == s2"<<endl;
    else cout<<"s1 != s2"<<endl;
   
    if (s1!=s2)cout<<"s1 != s2"<<endl;
    else cout<<"s1 == s2"<<endl;
   
    if (s1>s2)cout<<"s1 > s2"<<endl;
    else cout<<"s1 <= s2"<<endl;
   
    if (s1<=s2)cout<<"s1 <= s2"<<endl;
    else cout<<"s1 > s2"<<endl;

    cin.get();
}
17)
//size(),length()  q回字符数量
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s = "abcdefg";
    cout<<s.size()<<endl;
    cout<<s.length()<<endl;

    cin.get();
}
18)
//max_size() q回字符的可能最大个?br>#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s = "abcdefg";
    cout<<s.max_size()<<endl;

    cin.get();
}
19)
//empty()  判断字符串是否ؓI?br>#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s ;
    if (s.empty())
        cout<<"s 为空."<<endl;
    else
        cout<<"s 不ؓI?"<<endl;

    s = s + "abcdefg";
    if (s.empty())
        cout<<"s 为空."<<endl;
    else
        cout<<"s 不ؓI?"<<endl;

    cin.get();
}
20)
// [ ], at() 存取单一字符
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s = "abcdefg1111";
   
    cout<<"use []:"<<endl;
    for(int i=0; i<s.length(); i++)
    {
        cout<<s[i]<<endl;
    }
    cout<<endl;

    cout<<"use at():"<<endl;
    for(int i=0; i<s.length(); i++)
    {
        cout<<s.at(i)<<endl;
    }
    cout<<endl;
   
    cin.get();
}
21)
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s = "abcdefg1111";
   
    const char * chs1 = s.c_str();
    const char * chs2 = s.data();

    cout<<"use at():"<<endl;
    int i;
    for(i=0; i<s.length(); i++)
    {
        cout<<"c_str() : "<<chs1[i]<<endl;
        cout<<"data() : "<<chs2[i]<<endl;
    }
    cout<<"c_str() : "<<chs1<<endl;
    cout<<"data() : "<<chs2<<endl;
    cout<<endl;
   
    cin.get();
}
22)
// substr() q回某个子字W串
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s = "abcdefg1111";
   
    string str = s.substr(5,3);//从烦?开?个字?br>    cout<<str<<endl;
   
    cin.get();
}
23)
// find 查找函数
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s = "abcdefg1111";
    string pattern = "fg";
    string::size_type pos;
    pos = s.find(pattern,0);        //从烦?开?查找W合字符?f"的头索引
    cout<<pos<<endl;
    string str = s.substr(pos,pattern.size());
    cout<<str<<endl;
    cin.get();
}
24)
// begin() end() 提供cMSTL的P代器支持
#include <string>
#include <iostream>
using namespace std;

void main()
{
    string s = "abcdefg1111";
    for(string::iterator iter = s.begin(); iter!=s.end(); iter++)
    {
        cout<<*iter<<endl;
    }
    cout<<endl;

    cin.get();
}
        一个C++字符串存在三U大:a)现有的字W数Q函数是size()和length()Q他们等效? Empty()用来查字W串是否为空。b)max_size() q个大小是指当前C++字符串最多能包含的字W数Q很可能和机器本w的限制或者字W串所在位|连l内存的大小有关pR我们一般情况下不用兛_他,应该大小 _我们用的。但是不够用的话Q会抛出length_error异常c)capacity()重新分配内存之前 string所能包含的最大字W数。这里另一个需要指出的是reserve()函数Q这个函Cؓstring重新分配内存。重新分配的大小由其参数军_Q? 默认参数?Q这时候会对stringq行非强制性羃?/span>

Leon916 2008-12-05 22:33 发表评论
]]>
std::Vector学习http://m.shnenglu.com/Leon916/archive/2008/12/05/68638.htmlLeon916Leon916Fri, 05 Dec 2008 05:21:00 GMThttp://m.shnenglu.com/Leon916/archive/2008/12/05/68638.htmlhttp://m.shnenglu.com/Leon916/comments/68638.htmlhttp://m.shnenglu.com/Leon916/archive/2008/12/05/68638.html#Feedback0http://m.shnenglu.com/Leon916/comments/commentRss/68638.htmlhttp://m.shnenglu.com/Leon916/services/trackbacks/68638.html 按上面的语法Q创Z个vectorQ是按照v?span style="color: #ff0000;">实际元素个数创徏新vector的。就是说Q如果v中元素是1,2,3,那么QvNew中的元素?,2,3Qƈ且,vNew?span style="color: #ff0000;">d?/span>也是3.
也就是:vNew的d量取决于v的实际元素个数?/span>

pVec->clear();
clear()只是删除[first,last)区间中的所有元素,但ƈ不释攑օ内存?

(std::vector  <int >)(*pVec)
也就是创Z个时对象vector <int>Q显Ӟq个临时对象的d量是取决?pVec的实际元素个数的Q而经q?
pVec->clear();的pVect的实际元素个数是0Q因此,pVec- >swap( (std::vector  <int >)(*pVec) ); 这个时对象与pVec交换后,它的d量变成了0?
Qvector中的swap()实现的是Q将first、last,end_of_storageQd量)依次交换Q?

因此Q实C*pVec没用内存的释放?

Leon916 2008-12-05 13:21 发表评论
]]>
W试?http://m.shnenglu.com/Leon916/archive/2008/10/28/65277.htmlLeon916Leon916Tue, 28 Oct 2008 00:54:00 GMThttp://m.shnenglu.com/Leon916/archive/2008/10/28/65277.htmlhttp://m.shnenglu.com/Leon916/comments/65277.htmlhttp://m.shnenglu.com/Leon916/archive/2008/10/28/65277.html#Feedback0http://m.shnenglu.com/Leon916/comments/commentRss/65277.htmlhttp://m.shnenglu.com/Leon916/services/trackbacks/65277.htmlcout << sizeof*(p) << endl;
请问q个的输出?

l过调试Q我发现sizeofQ(p)的值是p类型所占的字节数?br>char输出?QdoubleQ?.


char x[0];
x是什么类型?
我在VS2005下调试,l果是错?nbsp; cannot allocate an array of constant size 0 ?br>

Leon916 2008-10-28 08:54 发表评论
]]>
þù| ɫۺϾþþþĻ| ഺþ| ɫۺϾþҹɫƷ| þþƷAvӰƬ | þþþƷҰ| þ99Ʒ鶹ѿ| ޾Ʒþþþþò| þݺҹҹ2014| þ99ۺϾƷ| 99þۺϾƷ| þþþƷ| 97ȾþƵƷ99| þþƷ| Ʒþþþþþ| ھƷۺϾþþ40p| þù| Ƶþ| 91ƷɫۺϾþ| ĻþþƷˮ| ݺɫþ| ھƷžžþþƷ| ձƷþþþӰԺձ| ھƷþþþþҰ| ĻƷþþþþ3Dն| þĻƷѩ | ھƷžžþþƷ| þһŷպ | 99ŷƷþþѿ| þþþþþþ| þþƷ| 91Ʒ91þþþþ| þù߳׽ѹۿ| þþƷһۺ| ޹þþۺ| ձ޿һþ | þҹɫƷվ| 鶹AV뾫Ʒþ| þþƷ99Ʒ| ھƷþþþþþcoent | Ļþ|