using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace cuai
{
public partial class Form1 : Form
{
public int life=6;
public Form1()
{
InitializeComponent();
}

private void label1_Click(object sender, EventArgs e)
{

}

public class pro
{
public static int x = new Random().Next(1, 100);
}

private void button1_MouseClick(object sender, MouseEventArgs e)
{
int a;
a = pro.x;
string l=life.ToString();
int c = Convert.ToInt32(this.textBox1.Text.ToString());
int k = Convert.ToInt32(l);
while (k > 0)
{
if (a < c)
{
MessageBox.Show("你输入的值大了!你还有"+l+"次机会");
break;
}
else
{
if (a > c)
{
MessageBox.Show("你输入的值小了!你还有" + l + "次机会");
break;
}
else
{
MessageBox.Show("恭喜你,答对了!");
break;
}
}
}
while (k <= 0)
{
MessageBox.Show("你没有机会了!");
MessageBox.Show("继续游戏?");
life = 7;
break;
}
life -= 1;
}
}
}