猜数字

02.// All rights reserved.                     
04.// 完成日期:2014年 11 月 16日           
05.// 版 本 号:v1.0                      
07.// 问题描述:创建一个程序来求三角形。该程序提示用户输入数据,然后显示出三角形的三边。          
08.// 输入描述:三个三角形的边长,代表数值           
09.// 程序输出:辨别三角形 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 0;


            int rndnum;
            Random rnd = new Random();
            rndnum = rnd.Next(1, 100);


            //这里就是无限循环的开始,让用户一直猜
            while (true)
            {
                Console.WriteLine("请输入你猜的数");
                x = Convert.ToInt32(Console.ReadLine());


                //用户猜了一个数,我们断定有3钟情况
                if (x > rndnum)
                {
                    Console.WriteLine("对不起,你猜大了");
                }
                else if (x < rndnum)
                {
                    Console.WriteLine("对不起,你猜小了");
                }
                else
                {
                    //既不是大于,又不是小于,那就肯定是等于了
                    Console.WriteLine("你猜对了");
                    break;
                }


            }
            Console.Read();






        }
    }
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章