Sayi üreten kod aşağıda verilmiştir ayrıca proje dosyalarının linki de en altta bulunmaktadır indirip deneyebilirsiniz.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SayisalLoto
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Random rnd = new Random();
int [] Rndsayi = new int[6];
int sayac=8,j;
String lnstr;
listBox1.Items.Clear();
do
{
lnstr = "";
for (int i = 0; i < 6; i++)
{
Rndsayi[i] = rnd.Next(49) + 1;//1-49 sayiları dahil ve o aralıkta sayi üretmek için +1 yazıyoruz.
j=0;
while (j < i) //her satırda sayıların farklı olması için kontrol ediyoruz.
{
if (Rndsayi[j] == Rndsayi[i])//eğer aynı sayi üretilmişse yeni sayi üretiyor.
{
Rndsayi[i] = rnd.Next(49) + 1;
continue;
}
else j++; //değil ise bunu diziye kaydedip sonraki sayiyi üretiyor.
}
lnstr += Rndsayi[i].ToString() + " ";
}
listBox1.Items.Add(lnstr);
} while (--sayac >= 1);
}
}
}
[su_button url="http://www.papiculo.com/wp-content/uploads/2014/04/SayisalLoto.zip" target="blank" style="3d" background="#5d8b25" radius="5" icon="icon: cloud-download"]Sayisal Loto Proje dosyalarını indir[/su_button]
0 yorum:
Yorum Gönder