<?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=328&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Gentoo中文社区 / C 练习实例19]]></title>
		<link>https://www.gentoo-zh.org/viewtopic.php?id=328</link>
		<description><![CDATA[C 练习实例19 最近发表的帖子。]]></description>
		<lastBuildDate>Mon, 29 Aug 2022 07:06:28 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[C 练习实例19]]></title>
			<link>https://www.gentoo-zh.org/viewtopic.php?pid=334#p334</link>
			<description><![CDATA[<p>题目：一个数如果恰好等于它的因子之和，这个数就称为&quot;完数&quot;。例如6=1＋2＋3.编程找出1000以内的所有完数。</p><p>程序分析：请参照：C 练习实例14。</p><p>#include&lt;stdio.h&gt;<br />#define N 1000<br />int main()<br />{<br />&#160; &#160; int i,j,k,n,sum;<br />&#160; &#160; int a[256];<br />&#160; &#160; for(i=2;i&lt;=N;i++)<br />&#160; &#160; {<br />&#160; &#160; &#160; &#160; sum=a[0]=1;<br />&#160; &#160; &#160; &#160; k=0;<br />&#160; &#160; &#160; &#160; for(j=2;j&lt;=(i/2);j++)<br />&#160; &#160; &#160; &#160; {<br />&#160; &#160; &#160; &#160; &#160; &#160; if(i%j==0)<br />&#160; &#160; &#160; &#160; &#160; &#160; {<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; sum+=j;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; a[++k]=j;<br />&#160; &#160; &#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; &#160; &#160; <br />&#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; if(i==sum)<br />&#160; &#160; &#160; &#160; {<br />&#160; &#160; &#160; &#160; &#160; &#160; printf(&quot;%d=%d&quot;,i,a[0]);<br />&#160; &#160; &#160; &#160; &#160; &#160; for(n=1;n&lt;=k;n++)<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; printf(&quot;+%d&quot;,a[n]);<br />&#160; &#160; &#160; &#160; &#160; &#160; printf(&quot;\n&quot;);<br />&#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; <br />&#160; &#160; }<br />&#160; &#160; return 0;<br />}</p>]]></description>
			<author><![CDATA[dummy@example.com (batsom)]]></author>
			<pubDate>Mon, 29 Aug 2022 07:06:28 +0000</pubDate>
			<guid>https://www.gentoo-zh.org/viewtopic.php?pid=334#p334</guid>
		</item>
	</channel>
</rss>
