1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace Loto
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("LE LOTO\n");
//int nb = 0;
int nbtirage = 0;
bool nbok = false;
const int nb = 6;
int[] tabNb = { 2, 67, 69 };
DateTime date = DateTime.Now;
Random nbAleatoire = new Random();
Console.WriteLine("Tirage du " + date);
for (int i = 0; i <= nb - 1; i++)
{
while (!nbok)
{
nbtirage = tabNb[nbAleatoire.nextDouble(tabNb.length)];
nbok = nbExist(nbtirage, i, tabNb);
}
nbok = false;
tabNb[i] = nbtirage;
}
Console.WriteLine("Les 6 chiffres dans l'ordre du tirage :\n");
foreach (int nbAffiche in tabNb)
{
Console.Write(nbAffiche + " ");
}
Array.Sort(tabNb);
Console.WriteLine("\n\nLes 6 chiffres triés :");
foreach (int nbAffiche in tabNb)
{
Console.Write(nbAffiche + " ");
}
Console.Read();
}
static bool nbExist(int nb, int j, int[] tabNb)
{
for (int i = 0; i <= j; i++)
{
if (tabNb[i] == nb)
{
return false;
}
}
return true;
}
}
} |
Partager