C sharp 实现 猜数…

来源:互联网 发布:网络用语鱼是什么意思 编辑:程序博客网 时间:2024/06/05 19:55
namespace lianxi6._29_1
{
    class Program
    {
       static void Main(string[] args)
       {
           Random r =new Random();
           int b =r.Next(0, 100);
           int count= 1;
          Console.ReadLine("请输入您猜的数字:");
           cc:
           int a =int.Parse(Console.ReadLine());
           f(a,b);
           if (a ==b) { Console.Write("您猜对了,用了{0}次",count); }
          count++;
           gotocc;
          Console.ReadLine();
       }
       static void f(int a,int b)
       {       
           if (a >b)
           {
             Console.Write("您猜的数大了\n");
           }
           else if (a< b)
           {
              Console.Write("您猜的数小了\n");         
           }
          
       }
    }
}

注:小编刚开始学习C sharp ,后期还会优化以上代码:
阅读全文
0 0
原创粉丝点击