用C#做一个猜数字的游戏(每次单击按钮随机数字就变了,要求单击时随机数不变) 10
代码如下:()privatevoidbutton1_Click(objectsender,EventArgse){if(textBox1.Text==""){Messag...
代码如下:()
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{ MessageBox.Show("请输入一个数字"); }
else
{
int b=4;
//Random Random1 = new Random();
//b = 1 + Random1.Next(8);
int a = System.Int32.Parse(textBox1.Text);//语句1
Console.WriteLine(a + 1);//语句2
Console.WriteLine(textBox1.Text);//语句3
int result = int.Parse(textBox1.Text);
if (b == a)
{
MessageBox.Show("宾GO!猜对了");
this.Close();
}
else if (b < a)
{
MessageBox.Show("大小了");
}
if (b > a)
{
MessageBox.Show("太小了");
}
if (sun == 3 && b !=a )
{
MessageBox.Show("Game Over! 智商是硬伤");
this.Close();
}
sun++;
}
} 展开
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{ MessageBox.Show("请输入一个数字"); }
else
{
int b=4;
//Random Random1 = new Random();
//b = 1 + Random1.Next(8);
int a = System.Int32.Parse(textBox1.Text);//语句1
Console.WriteLine(a + 1);//语句2
Console.WriteLine(textBox1.Text);//语句3
int result = int.Parse(textBox1.Text);
if (b == a)
{
MessageBox.Show("宾GO!猜对了");
this.Close();
}
else if (b < a)
{
MessageBox.Show("大小了");
}
if (b > a)
{
MessageBox.Show("太小了");
}
if (sun == 3 && b !=a )
{
MessageBox.Show("Game Over! 智商是硬伤");
this.Close();
}
sun++;
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询