您的位置:首页 > 编程语言 > C#

2016年c#:猜数字

2016-03-25 16:21 399 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Random rd = new Random();
int d = rd.Next(0, 100);
for (int i = 0; i < 10; i++)
{
Console.WriteLine("请输入你要猜的数:");
string s;
int num;
s= Console.ReadLine();
num=int.Parse(s);
if (num > d)
{
Console.WriteLine("你输入的数大了!");
}
if (num < d)
{
Console.WriteLine("你输入的数小了!");
}
if (num == d)
{
Console.WriteLine("你猜中了!");
break;
}
}
Console.ReadKey();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: