猜随机数

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 WindowsFormsApplication1
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{

}
private void textBox1_TextChanged(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 = 0;
a = pro.x;
int c = Convert.ToInt32(this.textBox1.Text.ToString());
if (a < c)
{
MessageBox.Show("你输入的值大了!");
}
else
{
if (a > c)
{
MessageBox.Show("你输入的值小了!");

}
else
{
MessageBox.Show("恭喜你,答对了!");
}
}

}
}
}

猜你喜欢

转载自www.cnblogs.com/wavexu/p/9934065.html