Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.65 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.         static Random rnd = new Random();
  19.         Button[] btn = new Button[100];
  20.         string namee;
  21.         int H = -1;
  22.         static int[] rast = new int[15];
  23.         int kontrol = 0;
  24.        
  25.  
  26.         private static void sayiuret()
  27.         {
  28.             int rand = rnd.Next(1, 100);
  29.             rast[0] = rand;
  30.             for (int i = 1; i < rast.Length; i++)
  31.             {
  32.                 rand = rnd.Next(1, 100);
  33.                 for (int j = 0; j <= i; j++)
  34.                 {
  35.                     if (rast[j] == rand)
  36.                     {
  37.                         i--;
  38.                         break;
  39.                     }
  40.                     else
  41.                         rast[j] = rnd.Next(1, 100) ;
  42.  
  43.                 }
  44.         }
  45.         }
  46.  
  47.         private void butonekle()
  48.         {
  49.             for (int i = 70; i <= 250; i += 20)
  50.             {
  51.                 for (int j = 25; j <= 205; j += 20)
  52.                 {
  53.                     H++;
  54.                     btn[H] = new Button();
  55.                     btn[H].CausesValidation = false;
  56.                     btn[H].Size = new System.Drawing.Size(20, 20);
  57.                     btn[H].Location = new System.Drawing.Point(j, i);
  58.                     btn[H].Name = ("btn");
  59.                     btn[H].Text = " ";
  60.                     namee = btn[H].Name;
  61.                     btn[H].Click += new System.EventHandler(namee_Click);
  62.                     this.Controls.Add(btn[H]);
  63.  
  64.                 }
  65.             }
  66.  
  67.             for (int i = 0; i < 15; i++)
  68.             {
  69.                
  70.             if (rast[i] == H)
  71.                 kontrol = 1;
  72.  
  73.             }
  74.         }
  75.  
  76.  
  77.         private void Form1_Load(object sender, EventArgs e)
  78.         {
  79.            
  80.                      
  81.            
  82.         }
  83.         private void namee_Click(object sender, EventArgs e)
  84.         {
  85.  
  86.             if (kontrol == 1)
  87.             {
  88.                 btn[H].Text = "X";
  89.                 btn[H].Enabled = false;
  90.             }
  91.             else
  92.                 btn[H].Text = "O";
  93.  
  94.            
  95.    
  96.  
  97.     kontrol = 0;
  98.     label1.Text = btn[H].Text;
  99. }
  100.  
  101.    
  102.         private void button1_Click(object sender, EventArgs e)
  103.         {
  104.             butonekle();
  105.             sayiuret();
  106.              
  107.  
  108.          }        
  109.         }
  110.        }
  111. 9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement