码迷,mamicode.com
首页 > 其他好文 > 详细

猜数字

时间:2014-09-30 10:20:22      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:io   ar   sp   c   on   cti   r   ad   line   

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();
        }
    }
    
}

猜数字

标签:io   ar   sp   c   on   cti   r   ad   line   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!