<?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=338&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Gentoo中文社区 / C 练习实例29]]></title>
		<link>https://www.gentoo-zh.org/viewtopic.php?id=338</link>
		<description><![CDATA[C 练习实例29 最近发表的帖子。]]></description>
		<lastBuildDate>Mon, 29 Aug 2022 07:11:47 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[C 练习实例29]]></title>
			<link>https://www.gentoo-zh.org/viewtopic.php?pid=344#p344</link>
			<description><![CDATA[<p>题目：给一个不多于5位的正整数，要求：一、求它是几位数，二、逆序打印出各位数字。</p><p>程序分析：学会分解出每一位数，如下解释。 </p><p>#include &lt;stdio.h&gt;</p><p>int main( )<br />{<br />&#160; &#160; long a,b,c,d,e,x;<br />&#160; &#160; printf(&quot;请输入 5 位数字：&quot;);<br />&#160; &#160; scanf(&quot;%ld&quot;,&amp;x);<br />&#160; &#160; a=x/10000;&#160; &#160; &#160; &#160; /*分解出万位*/<br />&#160; &#160; b=x%10000/1000;&#160; &#160;/*分解出千位*/<br />&#160; &#160; c=x%1000/100;&#160; &#160; &#160;/*分解出百位*/<br />&#160; &#160; d=x%100/10;&#160; &#160; &#160; &#160;/*分解出十位*/<br />&#160; &#160; e=x%10;&#160; &#160; &#160; &#160; &#160; &#160;/*分解出个位*/<br />&#160; &#160; if (a!=0){<br />&#160; &#160; &#160; &#160; printf(&quot;为 5 位数,逆序为： %ld %ld %ld %ld %ld\n&quot;,e,d,c,b,a);<br />&#160; &#160; } else if(b!=0) {<br />&#160; &#160; &#160; &#160; &#160;printf(&quot;为 4 位数,逆序为： %ld %ld %ld %ld\n&quot;,e,d,c,b);<br />&#160; &#160; } else if(c!=0) {<br />&#160; &#160; &#160; &#160; &#160;printf(&quot;为 3 位数,逆序为：%ld %ld %ld\n&quot;,e,d,c);<br />&#160; &#160; } else if(d!=0) {<br />&#160; &#160; &#160; &#160; &#160;printf(&quot;为 2 位数,逆序为： %ld %ld\n&quot;,e,d);<br />&#160; &#160; } else if(e!=0) {<br />&#160; &#160; &#160; &#160; &#160;printf(&quot;为 1 位数,逆序为：%ld\n&quot;,e);<br />&#160; &#160; }<br />}</p>]]></description>
			<author><![CDATA[dummy@example.com (batsom)]]></author>
			<pubDate>Mon, 29 Aug 2022 07:11:47 +0000</pubDate>
			<guid>https://www.gentoo-zh.org/viewtopic.php?pid=344#p344</guid>
		</item>
	</channel>
</rss>
