Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- static Random rnd = new Random();
- Button[] btn = new Button[100];
- string namee;
- int H = -1;
- static int[] rast = new int[15];
- int kontrol = 0;
- private static void sayiuret()
- {
- int rand = rnd.Next(1, 100);
- rast[0] = rand;
- for (int i = 1; i < rast.Length; i++)
- {
- rand = rnd.Next(1, 100);
- for (int j = 0; j <= i; j++)
- {
- if (rast[j] == rand)
- {
- i--;
- break;
- }
- else
- rast[j] = rnd.Next(1, 100) ;
- }
- }
- }
- private void butonekle()
- {
- for (int i = 70; i <= 250; i += 20)
- {
- for (int j = 25; j <= 205; j += 20)
- {
- H++;
- btn[H] = new Button();
- btn[H].CausesValidation = false;
- btn[H].Size = new System.Drawing.Size(20, 20);
- btn[H].Location = new System.Drawing.Point(j, i);
- btn[H].Name = ("btn");
- btn[H].Text = " ";
- namee = btn[H].Name;
- btn[H].Click += new System.EventHandler(namee_Click);
- this.Controls.Add(btn[H]);
- }
- }
- for (int i = 0; i < 15; i++)
- {
- if (rast[i] == H)
- kontrol = 1;
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void namee_Click(object sender, EventArgs e)
- {
- if (kontrol == 1)
- {
- btn[H].Text = "X";
- btn[H].Enabled = false;
- }
- else
- btn[H].Text = "O";
- kontrol = 0;
- label1.Text = btn[H].Text;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- butonekle();
- sayiuret();
- }
- }
- }
- 9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement