首页 > 其他 > 详细

猜数字

时间:2014-09-30 09:28:13      阅读:266      评论:0      收藏:0      [点我收藏+]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Random rd = new Random();
            int real = rd.Next(100) + 1;
            Console.WriteLine("随即输入1-100的整数:");
           
            do
            {
                string s = Console.ReadLine();
                int x = int.Parse(s);
                if (x > real)
             {
                 Console.WriteLine("大了!");
             }
                else if (x < real)
             {
                 Console.WriteLine("小了!");
             }
              else
                {
                    Console.WriteLine("恭喜你猜对了!");
                    break;
                }
            }
            while (true);
            Console.ReadKey();
        }
    }
    
}

猜数字

原文:http://blog.csdn.net/zjx211314/article/details/39692115

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!