11/28產生亂數(亂數重複)
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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication8
{
public partial class Form1 : Form
{
int i;
Button[,] buttons = new Button[5, 5];
{
public partial class Form1 : Form
{
int i;
Button[,] buttons = new Button[5, 5];
Random ran = new Random();
public Form1()
{
InitializeComponent();
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 1; i <=4; i++)
{
for (int j = 1; j <=4 ; j++)
{
int c = ran.Next(1, 15);
{
for (int i = 1; i <=4; i++)
{
for (int j = 1; j <=4 ; j++)
{
int c = ran.Next(1, 15);
buttons[i, j] = new Button();
buttons[i, j].Location = new Point(i * 50, j * 50);
buttons[i, j].Size = new Size(50, 50);
buttons[i, j].BackColor = Color.White;
this.Controls.Add(buttons[i, j]);
buttons[i, j].Location = new Point(i * 50, j * 50);
buttons[i, j].Size = new Size(50, 50);
buttons[i, j].BackColor = Color.White;
this.Controls.Add(buttons[i, j]);
buttons[i, j].Text = Convert.ToString(c);
}
}
}
}
}
}
}
}
}
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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication10
{
{
public partial class Form1 : Form
{
Button[,] buttons = new Button[10, 10];
public Form1()
{
InitializeComponent();
}
{
Button[,] buttons = new Button[10, 10];
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= 9; j++)
{
buttons[i, j] = new Button();
buttons[i, j].Location = new Point(i * 50, j * 50);
buttons[i, j].Size = new Size(50, 50);
buttons[i, j].BackColor = Color.White;
buttons[i, j].Text = (i*j).ToString();
this.Controls.Add(buttons[i, j]);
}
}
}
}
}
{
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= 9; j++)
{
buttons[i, j] = new Button();
buttons[i, j].Location = new Point(i * 50, j * 50);
buttons[i, j].Size = new Size(50, 50);
buttons[i, j].BackColor = Color.White;
buttons[i, j].Text = (i*j).ToString();
this.Controls.Add(buttons[i, j]);
}
}
}
}
}
0 個意見:
張貼留言
訂閱 張貼留言 [Atom]
<< 首頁