<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://www.gentoo-zh.org/extern.php?action=feed&amp;tid=321&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Gentoo中文社区 / C 练习实例12]]></title>
		<link>https://www.gentoo-zh.org/viewtopic.php?id=321</link>
		<description><![CDATA[C 练习实例12 最近发表的帖子。]]></description>
		<lastBuildDate>Mon, 29 Aug 2022 07:02:03 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[C 练习实例12]]></title>
			<link>https://www.gentoo-zh.org/viewtopic.php?pid=327#p327</link>
			<description><![CDATA[<p>题目：判断 101 到 200 之间的素数。</p><p>程序分析：判断素数的方法：用一个数分别去除 2 到 sqrt(这个数)，如果能被整除，则表明此数不是素数，反之是素数。 </p><br /><p>#include &lt;stdio.h&gt;</p><p>int main()<br />{<br />&#160; &#160; int i,j;<br />&#160; &#160; int count=0;<br />&#160; &#160; <br />&#160; &#160; for (i=101; i&lt;=200; i++) <br />&#160; &#160; {<br />&#160; &#160; &#160; &#160; for (j=2; j&lt;i; j++) <br />&#160; &#160; &#160; &#160; {<br />&#160; &#160; &#160; &#160; // 如果 j 能被 i 整除再跳出循环<br />&#160; &#160; &#160; &#160; &#160; &#160; if (i%j==0) <br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; break;<br />&#160; &#160; &#160; &#160; }<br />&#160; &#160; // 判断循环是否提前跳出，如果 j&lt;i 说明在 2~j 之间,i 有可整除的数<br />&#160; &#160; &#160; &#160; if (j&gt;=i) <br />&#160; &#160; &#160; &#160; {<br />&#160; &#160; &#160; &#160; &#160; &#160; count++;<br />&#160; &#160; &#160; &#160; &#160; &#160; printf(&quot;%d &quot;,i);<br />&#160; &#160; &#160; &#160; // 换行，用 count 计数，每五个数换行<br />&#160; &#160; &#160; &#160; &#160; &#160; if (count % 5 == 0) <br />&#160; &#160; &#160; &#160; &#160; &#160; printf(&quot;\n&quot;);<br />&#160; &#160; &#160; &#160; }<br />&#160; &#160; }&#160; &#160; <br />&#160; &#160; return 0;<br />}</p>]]></description>
			<author><![CDATA[dummy@example.com (batsom)]]></author>
			<pubDate>Mon, 29 Aug 2022 07:02:03 +0000</pubDate>
			<guid>https://www.gentoo-zh.org/viewtopic.php?pid=327#p327</guid>
		</item>
	</channel>
</rss>
