Sayısal loto - rasgele birbirinden farklı 6 tane sayı üretir(c#)da

murat335

New member
PHP:
Program : Sayısal loto (rasgele birbirinden farklı 6 tane sayı üretir.) 
( Consol uygulaması. Windows application değil.) 

yazar : murat335
------------------------------------------------------------------------------------ 

using System; 
using System.Collections.Generic; 
using System.Text; 

namespace ConsoleApplication1 
{ 
class Program 
{ 
static void Main(string[] args) 
{ 
int[] dizi = new int[6]; 
int sayi = 0, j=0; 
bool buldu = false; 
Random rasgele = new Random(); 

for (int i = 0; i < 6; i++) 
{ 
buldu = false; 
while (buldu == false) 
{ 
sayi = rasgele.Next(1, 50); 
for (j = 0; j < 6; j++) 
{ 
if (dizi[j] == sayi) break; 

} 
if (j == 6) 
{ 
dizi[i] = sayi; 
buldu = true; 
} 

} 

} 

for (int i = 0; i < 6; i++) 
{ 
Console.WriteLine(dizi[i]); 
} 

} 
} 
}
_________________
 

HTML

Üst