Copyright (c) 2014软件技术1班
03.// All rights reserved.
04.// 作 者:A20
05.// 完成日期:2014年 11 月 16日
06.// 版 本 号:v1.0
07.//
namespace ConsoleApplication22
{
class Program
{
static void Main(string[] args)
{
int a ,rndNum;
Console.WriteLine("请输入一个1到100的数");
Random rnd = new Random();
rndNum = rnd.Next(1,100);
while (true)
{a = Convert.ToInt32(Console.ReadLine());
if (a > rndNum)
Console.WriteLine("对不起,你猜大了");
else if (a < rndNum)
Console.WriteLine("对不起,你猜小了");
else
{
Console.WriteLine("恭喜你猜对了");
break;
}
}
Console.Read();
}
}
}
<img src="https://img-blog.csdn.net/20141116143253890?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQva2s1NTM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
总结;刚刚开始因为赋值放错位置程序老出错,不过经过多次调试找到错的地方并改对了。
猜数游戏
最新推荐文章于 2022-08-08 22:43:32 发布