89 lines
2.6 KiB
C#
89 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Reflection.Emit;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
namespace Lotto
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
int[] sorsoltak = new int[5];
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
Random rd = new Random();
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
bool marvan;
|
|
do
|
|
{
|
|
sorsoltak[i] = rd.Next(1, 91);
|
|
marvan = false;
|
|
for (int j = 0; j < i; j++)
|
|
{
|
|
marvan = marvan || (sorsoltak[j] == sorsoltak[i]);
|
|
}
|
|
} while (marvan);
|
|
}
|
|
|
|
Array.Sort(sorsoltak);
|
|
|
|
SorsolasCimke.Text = $"{sorsoltak[0]} {sorsoltak[1]} {sorsoltak[2]} {sorsoltak[3]} {sorsoltak[4]}";
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
string beirva = textBox1.Text;
|
|
string[] szamok = beirva.Split(';');
|
|
if (szamok.Length != 5)
|
|
{
|
|
label2.Text = "Nem öt értéket adott meg vagy nem jó a választókarakter!";
|
|
}
|
|
else
|
|
{
|
|
int talalat = 0;
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
try
|
|
{
|
|
int lsz = int.Parse(szamok[i]);
|
|
if (lsz < 1 || lsz > 90)
|
|
{
|
|
label2.Text = $"Az {i + 1}. szám nem 1-90 közötti!";
|
|
talalat = -1;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
foreach (int s in sorsoltak)
|
|
{
|
|
if (s == lsz) talalat++;
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception)
|
|
{
|
|
label2.Text = $"Az {i + 1}. érték nem szám!";
|
|
talalat = -1;
|
|
break;
|
|
}
|
|
}
|
|
if (talalat > -1) label2.Text = "Találatok száma: " + talalat;
|
|
}
|
|
}
|
|
|
|
}
|
|
} |