<?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=340&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Gentoo中文社区 / C 练习实例31]]></title>
		<link>https://www.gentoo-zh.org/viewtopic.php?id=340</link>
		<description><![CDATA[C 练习实例31 最近发表的帖子。]]></description>
		<lastBuildDate>Mon, 29 Aug 2022 07:12:38 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[C 练习实例31]]></title>
			<link>https://www.gentoo-zh.org/viewtopic.php?pid=346#p346</link>
			<description><![CDATA[<p>题目：请输入星期几的第一个字母来判断一下是星期几，如果第一个字母一样，则继续判断第二个字母。</p><p>程序分析：用情况语句比较好，如果第一个字母一样，则判断用情况语句或if语句判断第二个字母。 </p><p>#include&lt;stdio.h&gt;</p><p>int main()<br />{<br />&#160; &#160; char i,j;<br />&#160; &#160; printf(&quot;请输入第一个字母:\n&quot;);<br />&#160; &#160; scanf(&quot;%c&quot;,&amp;i);<br />&#160; &#160; getchar();//scanf(&quot;%c&quot;,&amp;j);的问题，第二次是读入的一个换行符，而不是输入的字符，因此需要加一个getchar() 吃掉换行符<br />&#160; &#160; switch(i)<br />&#160; &#160; {<br />&#160; &#160; &#160; &#160; case &#039;m&#039;:<br />&#160; &#160; &#160; &#160; &#160; &#160; printf(&quot;monday\n&quot;);<br />&#160; &#160; &#160; &#160; &#160; &#160; break;<br />&#160; &#160; &#160; &#160; case &#039;w&#039;:<br />&#160; &#160; &#160; &#160; &#160; &#160; printf(&quot;wednesday\n&quot;);<br />&#160; &#160; &#160; &#160; &#160; &#160; break;<br />&#160; &#160; &#160; &#160; case &#039;f&#039;:<br />&#160; &#160; &#160; &#160; &#160; &#160; printf(&quot;friday\n&quot;);<br />&#160; &#160; &#160; &#160; &#160; &#160; break;<br />&#160; &#160; &#160; &#160; case &#039;t&#039;:<br />&#160; &#160; &#160; &#160; &#160; &#160; printf(&quot;请输入下一个字母\n&quot;);<br />&#160; &#160; &#160; &#160; &#160; &#160; scanf(&quot;%c&quot;,&amp;j);<br />&#160; &#160; &#160; &#160; &#160; &#160; if (j==&#039;u&#039;) {printf(&quot;tuesday\n&quot;);break;}<br />&#160; &#160; &#160; &#160; &#160; &#160; if (j==&#039;h&#039;) {printf(&quot;thursday\n&quot;);break;}<br />&#160; &#160; &#160; &#160; case &#039;s&#039;:<br />&#160; &#160; &#160; &#160; &#160; &#160; printf(&quot;请输入下一个字母\n&quot;);<br />&#160; &#160; &#160; &#160; &#160; &#160; scanf(&quot;%c&quot;,&amp;j);<br />&#160; &#160; &#160; &#160; &#160; &#160; if (j==&#039;a&#039;) {printf(&quot;saturday\n&quot;);break;}<br />&#160; &#160; &#160; &#160; &#160; &#160; if (j==&#039;u&#039;) {printf(&quot;sunday\n&quot;); break;}<br />&#160; &#160; &#160; &#160; default :<br />&#160; &#160; &#160; &#160; &#160; &#160; printf(&quot;error\n&quot;); break;<br />&#160; &#160; }<br />&#160; &#160; return 0;<br />}</p>]]></description>
			<author><![CDATA[dummy@example.com (batsom)]]></author>
			<pubDate>Mon, 29 Aug 2022 07:12:38 +0000</pubDate>
			<guid>https://www.gentoo-zh.org/viewtopic.php?pid=346#p346</guid>
		</item>
	</channel>
</rss>
