<?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=403&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Gentoo中文社区 / C 练习实例94]]></title>
		<link>https://www.gentoo-zh.org/viewtopic.php?id=403</link>
		<description><![CDATA[C 练习实例94 最近发表的帖子。]]></description>
		<lastBuildDate>Mon, 29 Aug 2022 11:55:17 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[C 练习实例94]]></title>
			<link>https://www.gentoo-zh.org/viewtopic.php?pid=409#p409</link>
			<description><![CDATA[<p>题目：猜谜游戏。</p><p>程序分析：无。</p><br /><div class="codebox"><pre class="vscroll"><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;
 
void caizi(void)
{
    int n;
    char begin;
    int count = 1;
    srand((int)time(NULL));
    int m = (rand() % 100) + 1;
    puts(&quot;游戏开始，请输入数字:&quot;);
    while (1)
    {
        scanf(&quot;%d&quot;, &amp;n);
        if (n == m)
        {
            printf(&quot;猜中了，使用了 %d 次！\n&quot;, count);
            if (count == 1)
            {
                printf(&quot;你是神级人物了！膜拜\n&quot;);
                getchar();
                printf(&quot;你已经达到最高级别，还需要玩吗？Y/N \n&quot;);
                scanf(&quot;%c&quot;, &amp;begin);
                if (begin == &#039;Y&#039; || begin == &#039;y&#039;)      //重复玩的一个嵌套循环
                {
                    caizi();
                }
                else
                {
                    printf(&quot;谢谢，再见!\n&quot;);
                }
            }
            else if (count &lt;= 5)
            {
                printf(&quot;你是王级人物了！非常赞\n&quot;);
                getchar();
                printf(&quot;需要挑战最高级别不？Y/N \n&quot;);
                scanf(&quot;%c&quot;, &amp;begin);
                if (begin == &#039;Y&#039; || begin == &#039;y&#039;)
                {
                    caizi();
                }
                else
                {
                    printf(&quot;谢谢，再见!\n&quot;);
                }
            }
            else if (count &lt;= 10)
            {
                printf(&quot;你是大师级人物了！狂赞\n&quot;);
                getchar();
                printf(&quot;需要挑战最高级别不？Y/N \n&quot;);
                scanf(&quot;%c&quot;, &amp;begin);
                if (begin == &#039;Y&#039; || begin == &#039;y&#039;)
                {
                    caizi();
                }
                else
                {
                    printf(&quot;谢谢，再见!\n&quot;);
                }
            }
            else if (count &lt;= 15)
            {
                printf(&quot;你是钻石级人物了！怒赞\n&quot;);
                getchar();
                printf(&quot;需要挑战最高级别不？Y/N \n&quot;);
                scanf(&quot;%c&quot;, &amp;begin);
                if (begin == &#039;Y&#039; || begin == &#039;y&#039;)
                {
                    caizi();
                }
                else
                {
                    printf(&quot;谢谢，再见!\n&quot;);
                }
            }
            else
            {
                getchar();
                printf(&quot;你的技术还有待提高哦！重玩？ Y/N\n&quot;);
                scanf(&quot;%c&quot;,&amp;begin);
                if (begin == &#039;Y&#039; || begin == &#039;y&#039;)
                {
                    caizi();
                }
                else
                {
                    printf(&quot;谢谢，再见!\n&quot;);
                }
            }
            break;
        }
        else if (n &lt; m)
        {
            puts(&quot;太小了!&quot;);
            puts(&quot;重新输入:&quot;);
        }
        else
        {
            puts(&quot;太大了!&quot;);
            puts(&quot;重新输入:&quot;);
        }
        count++;//计数器
        
        
    }
}
 
 
int main(void)
{
    
    caizi();
    system(&quot;pause&quot;);
    return 0;
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (batsom)]]></author>
			<pubDate>Mon, 29 Aug 2022 11:55:17 +0000</pubDate>
			<guid>https://www.gentoo-zh.org/viewtopic.php?pid=409#p409</guid>
		</item>
	</channel>
</rss>
