Sayısal Loto [C#]

C#’ta sayısal loto yapımını birlikte inceleyelim…

Sayısal-Loto

 

 

 

 

 

 

 

 

 

 

  

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace WindowsApplication3

{

    public partial class Form1 : Form

    {

        int[] sayi = new int[6];

        int[] sayi1 = new int[6];

         public Form1()

        {

            InitializeComponent();

        }

       // ÇEKİLİŞ BUTONU

        private void button1_Click(object sender, EventArgs e)

        {

            int i, j, a, sayac = 1;

            textBox1.Text = “”;

            textBox2.Text = “”;

            Random rnd = new Random();

            for (i = 0; i <= 5; i++)

            {

                sayi[i] = rnd.Next(1, 49);

                textBox1.Text = textBox1.Text + ” ” + Convert.ToInt32(sayi[i]);

            }

            while (sayac == 1)

            {

sayac = 0;

                for (i = 0; i <= 4; i++)

                {

                    for (j = i + 1; j <= 5; j++)

                    {

                       // KARŞILAŞTIRMA VE SIRALAMA İŞLEMİ  

                        if (sayi[i] > sayi[j])

                        {  

                            a = sayi[i];

                            sayi[i] = sayi[j];

                            sayi[j] = a;

                        }

                        if (sayi[i] == sayi[j])

                        {

                            sayac = sayac + 1;

                            sayi[j] = rnd.Next(1, 49);

                            break;

                        }

                    }

                    if (sayac == 1)

                        break;

                }

            }

            for (i = 0; i <= 5; i++)

                textBox2.Text = textBox2.Text + ” ” + Convert.ToInt32(sayi[i]);

 }

//BAŞLA BUTONU

        private void button2_Click(object sender, EventArgs e)

        {

            int i, j, a, top, sayac, g;

            Random rnd = new Random();

            textBox4.Text = “0” ;

            textBox5.Text = “0” ;

            textBox6.Text = “0” ;

            textBox7.Text = “0” ;

            textBox8.Text = “0” ;

            textBox9.Text = “0” ;

            textBox10.Text = “0 “ ;

            listBox1.Items.Clear();

            listBox2.Items.Clear();

for (g=1; g<=Convert.ToInt32(textBox3.Text); g++)

            {

                for (i=0; i<=5; i++)

                {

                    sayi1[i]=rnd.Next(1,49);

                }

                sayac=1;

                while (sayac==1)

                {

                    sayac=0;

                    for (i=0; i<=4; i++)

                    {

                        for (j=i+1; j<=5; j++)

                        {

                            if(sayi1[i]>sayi1[j])

                            {

                                a=sayi1[i];

                                sayi1[i]=sayi1[j];

                                sayi1[j]=a;

                            }

                            if (sayi1[i]==sayi1[j])

                            {

                                sayac=sayac+1;

                                sayi1[j]=rnd.Next(1,49);

                                break;

                            }

                        }

                        if (sayac==1)

                            break;

                    }

                }

                listBox1.Items.Add(g+ “inci” + ” “ +Convert.ToInt32(sayi1[0])+ ” “ +Convert.ToInt32(sayi1[1])+ ” “ + Convert.ToInt32(sayi1[2])+ ” “ +Convert.ToInt32(sayi1[3])+ ” “ +Convert.ToInt32(sayi1[4])+ ” “ +Convert.ToInt32(sayi1[5]));

                top=0;

                for(i=0; i<=5; i++)

                    for(j=0; j<=5; j++)

                        if (sayi[i]==sayi1[j])

                            top=top+1;

if (top==0) 

textBox4.Text=Convert.ToString(Convert.ToInt32(textBox4.Text)+1);

 if (top==1)                   

textBox5.Text=Convert.ToString(Convert.ToInt32(textBox5.Text)+1);

if (top==2)                   

textBox6.Text=Convert.ToString(Convert.ToInt32(textBox6.Text)+1);

 if (top==3)                  

textBox7.Text=Convert.ToString(Convert.ToInt32(textBox7.Text)+1);

 if (top==4)                   

 textBox8.Text=Convert.ToString(Convert.ToInt32(textBox8.Text)+1);

 if (top==5)                   

textBox9.Text=Convert.ToString(Convert.ToInt32(textBox9.Text)+1);

 if (top==6)                  

 textBox10.Text=Convert.ToString(Convert.ToInt32(textBox10.Text)+1);

// ÜÇ BİLENDEN BAŞLADIK ÇÜNKÜ PARA ORDA 🙂

if (top==3)

listBox2.Items.Add(g+ “inci” + ” “ +sayi1[0]+ ” “ +sayi1[1]+ ” ” +sayi1[2]+ ” “ +sayi1[3]+ ” “ +sayi1[4]+ ” “ + sayi1[5]+ ” -Üç Bilen” );

 if (top==4)

listBox2.Items.Add(g+ “inci” + ” “ +sayi1[0]+ ” “ +sayi1[1]+ ” “ +sayi1[2]+ ” “ +sayi1[3]+ ” “ +sayi1[4]+ ” ” +sayi1[5]+” -Dört Bilen” );

 if (top==5)

listBox2.Items.Add(g+ “inci” + ” “ +sayi1[0]+ ” “ +sayi1[1]+ ” “ +sayi1[2]+ “ +sayi1[3]+ ” “ +sayi1[4]+ ” “ +sayi1[5]+ ” -Beş Bilen” );

 if (top==6)

listBox2.Items.Add(g+ “inci” + ” “ +sayi1[0]+ ” “ +sayi1[1]+ ” “ +sayi1[2]+ ” “ +sayi1[3]+ ” “ +sayi1[4]+ ” “ +sayi1[5]+” -Altı Bilen” );

            }

 }

       private void textBox4_TextChanged(object sender, EventArgs e)

        {

            textBox4.Refresh();

        }

         private void textBox5_TextChanged(object sender, EventArgs e)

        {

            textBox5.Refresh();

        }

         private void textBox6_TextChanged(object sender, EventArgs e)

        {

            textBox6.Refresh();

        }

         private void textBox7_TextChanged(object sender, EventArgs e)

        {

            textBox7.Refresh();

        }

        private void textBox8_TextChanged(object sender, EventArgs e)

        {

            textBox8.Refresh();

        }

         private void textBox9_TextChanged(object sender, EventArgs e)

        {

            textBox9.Refresh();

        }

         private void textBox10_TextChanged(object sender, EventArgs e)

        {

            textBox10.Refresh();

        }

       }

}

Yazar: Tansu

Tansu DİLİ sitemizde 5 yazı eklemiş...

Share