﻿<?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>BlogJava-ljf2999-文章分类-Arithmetic</title><link>http://www.blogjava.net/ljf2999/category/17900.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 28 Feb 2007 07:42:46 GMT</lastBuildDate><pubDate>Wed, 28 Feb 2007 07:42:46 GMT</pubDate><ttl>60</ttl><item><title>Joseph Circle</title><link>http://www.blogjava.net/ljf2999/articles/83255.html</link><dc:creator>ljf2999</dc:creator><author>ljf2999</author><pubDate>Fri, 24 Nov 2006 06:56:00 GMT</pubDate><guid>http://www.blogjava.net/ljf2999/articles/83255.html</guid><wfw:comment>http://www.blogjava.net/ljf2999/comments/83255.html</wfw:comment><comments>http://www.blogjava.net/ljf2999/articles/83255.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ljf2999/comments/commentRss/83255.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ljf2999/services/trackbacks/83255.html</trackback:ping><description><![CDATA[
		<p> </p>
		<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 id="Codehighlighter1_22_798_Open_Image" onclick="this.style.display='none'; Codehighlighter1_22_798_Open_Text.style.display='none'; Codehighlighter1_22_798_Closed_Image.style.display='inline'; Codehighlighter1_22_798_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
				<img id="Codehighlighter1_22_798_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_22_798_Closed_Text.style.display='none'; Codehighlighter1_22_798_Open_Image.style.display='inline'; Codehighlighter1_22_798_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> Josephus </span>
				<span id="Codehighlighter1_22_798_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://www.blogjava.net/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_22_798_Open_Text">
						<span style="COLOR: #000000">{<br /></span>
						<span style="COLOR: #008080"> 2</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080"> 3</span>
						<span style="COLOR: #000000">
								<img id="Codehighlighter1_68_796_Open_Image" onclick="this.style.display='none'; Codehighlighter1_68_796_Open_Text.style.display='none'; Codehighlighter1_68_796_Closed_Image.style.display='inline'; Codehighlighter1_68_796_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_68_796_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_68_796_Closed_Text.style.display='none'; Codehighlighter1_68_796_Open_Image.style.display='inline'; Codehighlighter1_68_796_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">static</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> main(String[] args) </span>
						<span id="Codehighlighter1_68_796_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://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_68_796_Open_Text">
								<span style="COLOR: #000000">{<br /></span>
								<span style="COLOR: #008080"> 4</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_95_175_Open_Image" onclick="this.style.display='none'; Codehighlighter1_95_175_Open_Text.style.display='none'; Codehighlighter1_95_175_Closed_Image.style.display='inline'; Codehighlighter1_95_175_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_95_175_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_95_175_Closed_Text.style.display='none'; Codehighlighter1_95_175_Open_Image.style.display='inline'; Codehighlighter1_95_175_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(args.length</span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">2</span>
								<span style="COLOR: #000000">)</span>
								<span id="Codehighlighter1_95_175_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://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_95_175_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080"> 5</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            System.out.println(</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">Input N and M.</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">);<br /></span>
										<span style="COLOR: #008080"> 6</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">return</span>
										<span style="COLOR: #000000">;<br /></span>
										<span style="COLOR: #008080"> 7</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080"> 8</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> n </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> Integer.parseInt(args[</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">]);<br /></span>
								<span style="COLOR: #008080"> 9</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> m </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> Integer.parseInt(args[</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">]);<br /></span>
								<span style="COLOR: #008080">10</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> point</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">,number</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /></span>
								<span style="COLOR: #008080">11</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        List</span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">Integer</span>
								<span style="COLOR: #000000">&gt;</span>
								<span style="COLOR: #000000"> list </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">new</span>
								<span style="COLOR: #000000"> ArrayList</span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">Integer</span>
								<span style="COLOR: #000000">&gt;</span>
								<span style="COLOR: #000000">();<br /></span>
								<span style="COLOR: #008080">12</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_378_433_Open_Image" onclick="this.style.display='none'; Codehighlighter1_378_433_Open_Text.style.display='none'; Codehighlighter1_378_433_Closed_Image.style.display='inline'; Codehighlighter1_378_433_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_378_433_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_378_433_Closed_Text.style.display='none'; Codehighlighter1_378_433_Open_Image.style.display='inline'; Codehighlighter1_378_433_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.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">1</span>
								<span style="COLOR: #000000">;i</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">n; i</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)</span>
								<span id="Codehighlighter1_378_433_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://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_378_433_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">13</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">初始化链表</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">14</span>
										<span style="COLOR: #008000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">            list.add(i);<br /></span>
										<span style="COLOR: #008080">15</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080">16</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
										<br />
								</span>
								<span style="COLOR: #008080">17</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_464_730_Open_Image" onclick="this.style.display='none'; Codehighlighter1_464_730_Open_Text.style.display='none'; Codehighlighter1_464_730_Closed_Image.style.display='inline'; Codehighlighter1_464_730_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_464_730_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_464_730_Closed_Text.style.display='none'; Codehighlighter1_464_730_Open_Image.style.display='inline'; Codehighlighter1_464_730_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">while</span>
								<span style="COLOR: #000000">(list.size()</span>
								<span style="COLOR: #000000">&gt;</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">)</span>
								<span id="Codehighlighter1_464_730_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://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_464_730_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">18</span>
										<span style="COLOR: #000000">
												<img id="Codehighlighter1_493_568_Open_Image" onclick="this.style.display='none'; Codehighlighter1_493_568_Open_Text.style.display='none'; Codehighlighter1_493_568_Closed_Image.style.display='inline'; Codehighlighter1_493_568_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
												<img id="Codehighlighter1_493_568_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_493_568_Closed_Text.style.display='none'; Codehighlighter1_493_568_Open_Image.style.display='inline'; Codehighlighter1_493_568_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000">(number</span>
										<span style="COLOR: #000000">%</span>
										<span style="COLOR: #000000">m</span>
										<span style="COLOR: #000000">==</span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">)</span>
										<span id="Codehighlighter1_493_568_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://www.blogjava.net/images/dot.gif" />
										</span>
										<span id="Codehighlighter1_493_568_Open_Text">
												<span style="COLOR: #000000">{<br /></span>
												<span style="COLOR: #008080">19</span>
												<span style="COLOR: #000000">
														<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                list.remove(point);<br /></span>
												<span style="COLOR: #008080">20</span>
												<span style="COLOR: #000000">
														<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
												<span style="COLOR: #000000">--</span>
												<span style="COLOR: #000000">point;<br /></span>
												<span style="COLOR: #008080">21</span>
												<span style="COLOR: #000000">
														<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
										</span>
										<span style="COLOR: #008080">22</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">point;</span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">指针后移</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">23</span>
										<span style="COLOR: #008000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">            </span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">number;<br /></span>
										<span style="COLOR: #008080">24</span>
										<span style="COLOR: #000000">
												<img id="Codehighlighter1_654_720_Open_Image" onclick="this.style.display='none'; Codehighlighter1_654_720_Open_Text.style.display='none'; Codehighlighter1_654_720_Closed_Image.style.display='inline'; Codehighlighter1_654_720_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
												<img id="Codehighlighter1_654_720_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_654_720_Closed_Text.style.display='none'; Codehighlighter1_654_720_Open_Image.style.display='inline'; Codehighlighter1_654_720_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000">(point</span>
										<span style="COLOR: #000000">&gt;</span>
										<span style="COLOR: #000000">list.size()</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">)</span>
										<span id="Codehighlighter1_654_720_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://www.blogjava.net/images/dot.gif" />
										</span>
										<span id="Codehighlighter1_654_720_Open_Text">
												<span style="COLOR: #000000">{<br /></span>
												<span style="COLOR: #008080">25</span>
												<span style="COLOR: #000000">
														<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
												<span style="COLOR: #008000">//</span>
												<span style="COLOR: #008000">指针越界重新开始</span>
												<span style="COLOR: #008000">
														<br />
												</span>
												<span style="COLOR: #008080">26</span>
												<span style="COLOR: #008000">
														<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
												</span>
												<span style="COLOR: #000000">                point</span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000">0</span>
												<span style="COLOR: #000000">;<br /></span>
												<span style="COLOR: #008080">27</span>
												<span style="COLOR: #000000">
														<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
										</span>
										<span style="COLOR: #008080">28</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080">29</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        <br /></span>
								<span style="COLOR: #008080">30</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
										<br />
								</span>
								<span style="COLOR: #008080">31</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        System.out.println(list.get(</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">));<br /></span>
								<span style="COLOR: #008080">32</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        <br /></span>
								<span style="COLOR: #008080">33</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080">34</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">35</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
<img src ="http://www.blogjava.net/ljf2999/aggbug/83255.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ljf2999/" target="_blank">ljf2999</a> 2006-11-24 14:56 <a href="http://www.blogjava.net/ljf2999/articles/83255.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>