标题:希望得到点评及意见
取消只看楼主
寂静夜
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2007-11-17
 问题点数:0 回复次数:0 
希望得到点评及意见
public  static void Main(string[] args)
        {
            string sTemp;
            int iNum = new Random().Next() % 100;
            int iGuess = 0;
            int iCount = 0;
            Console.WriteLine("请猜猜一到一百之间的数字.");
            do
            {
                    sTemp = Console.ReadLine();

        if (Convert.ToInt32(sTemp) > 100)
                    {
                        Console.WriteLine("你输入的数字超出了范围");
                        continue;
                    }
               
             try
                {
                    iGuess=Int32 .Parse(sTemp );
                    if (iGuess >iNum )
                    {
                        Console.WriteLine("太大了");
                    }
                    else if (iGuess<iNum )
                    {
                        Console.WriteLine("太小了");
                    }
                }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    finally
                    {
                        Console.WriteLine("你已经猜了{0}次了.",++iCount );
                    }
            }
            while (iGuess !=iNum);
        }
    }
这是我通过唐伯猫的小程序中拿来的
红色的部分是我更改的
不知道这个程序还有米有更多的更改地方
搜索更多相关主题的帖子: 点评 int 意见 sTemp Console 
2007-12-16 09:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-192720-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.279621 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved