猜数器
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication9
{
public partial class Form1 : Form
{
Random ra = new Random();
int Ra = 0;
int cishu = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
Ra = ra.Next(0,100);
}
private void button1_Click(object sender, EventArgs e)
{
string num = textBox1.Text.Trim();
int shu = Int32.Parse(num);
{
if (shu > Ra)
{
cishu++;
MessageBox.Show("你猜大了 " + "一共猜了" + cishu + "次");
}
else
{
if (shu < Ra)
{
cishu++;
MessageBox.Show("你猜小了 " + "一共猜了" + cishu + "次");
}