Lottó listákkal
This commit is contained in:
25
LottoLista/LottoLista.sln
Normal file
25
LottoLista/LottoLista.sln
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.14.36429.23 d17.14
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LottoLista", "LottoLista\LottoLista.csproj", "{36A8D202-B4E8-46B6-9D02-F9DB6F2F0100}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{36A8D202-B4E8-46B6-9D02-F9DB6F2F0100}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{36A8D202-B4E8-46B6-9D02-F9DB6F2F0100}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{36A8D202-B4E8-46B6-9D02-F9DB6F2F0100}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{36A8D202-B4E8-46B6-9D02-F9DB6F2F0100}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {2EC8B3BE-B408-424D-B245-45C545B61608}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
10
LottoLista/LottoLista/LottoLista.csproj
Normal file
10
LottoLista/LottoLista/LottoLista.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
98
LottoLista/LottoLista/Program.cs
Normal file
98
LottoLista/LottoLista/Program.cs
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
namespace LottoLista
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.Write("Hány számot sorsolunk?:");
|
||||||
|
int hanySzam = Convert.ToInt32(Console.ReadLine());
|
||||||
|
|
||||||
|
Console.Write("Hány számból húzunk?:");
|
||||||
|
int osszSzam = Convert.ToInt32(Console.ReadLine());
|
||||||
|
|
||||||
|
List<int> tippek = new List<int>();
|
||||||
|
List<int> nyeroSzamok = new List<int>();
|
||||||
|
List<int> sorsoloGomb = new List<int>();
|
||||||
|
Random rand = new Random();
|
||||||
|
int talalat = 0;
|
||||||
|
|
||||||
|
|
||||||
|
//"Sorsoló gömb" feltöltése
|
||||||
|
GombInit(osszSzam, sorsoloGomb);
|
||||||
|
|
||||||
|
//Tippelés
|
||||||
|
Tippeles(osszSzam, hanySzam, tippek);
|
||||||
|
|
||||||
|
Listazas(tippek);
|
||||||
|
|
||||||
|
//Sorsolás
|
||||||
|
Sorsolas(hanySzam, nyeroSzamok, sorsoloGomb, rand);
|
||||||
|
|
||||||
|
Listazas(nyeroSzamok);
|
||||||
|
|
||||||
|
//Találatok meghatározása
|
||||||
|
talalat = Talalat(hanySzam, tippek, nyeroSzamok, talalat);
|
||||||
|
Console.WriteLine($"Találat:{talalat}");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int Talalat(int hanySzam, List<int> tippek, List<int> nyeroSzamok, int talalat)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < hanySzam; i++)
|
||||||
|
{
|
||||||
|
if (nyeroSzamok.Contains(tippek[i]))
|
||||||
|
{
|
||||||
|
talalat++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return talalat;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Sorsolas(int hanySzam, List<int> nyeroSzamok, List<int> sorsoloGomb, Random rand)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < hanySzam; i++)
|
||||||
|
{
|
||||||
|
int kivalasztott = rand.Next(0, sorsoloGomb.Count);
|
||||||
|
nyeroSzamok.Add(sorsoloGomb[kivalasztott]);
|
||||||
|
sorsoloGomb.RemoveAt(kivalasztott);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Listazas(List<int> lista)
|
||||||
|
{
|
||||||
|
foreach (int i in lista)
|
||||||
|
{
|
||||||
|
Console.Write(i + " ");
|
||||||
|
}
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Tippeles(int osszSzam,int hanySzam, List<int> tippek)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < hanySzam; i++)
|
||||||
|
{
|
||||||
|
Console.Write($"{i + 1}.tipp:");
|
||||||
|
int temp = Convert.ToInt32(Console.ReadLine());
|
||||||
|
while (temp < 1 || temp > osszSzam || tippek.Contains(temp))
|
||||||
|
{
|
||||||
|
Console.Write($"Hiba!, Újra!{i + 1}.tipp:");
|
||||||
|
temp = Convert.ToInt32(Console.ReadLine());
|
||||||
|
}
|
||||||
|
tippek.Add(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void GombInit(int osszSzam, List<int> sorsoloGomb)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < osszSzam; i++)
|
||||||
|
{
|
||||||
|
sorsoloGomb.Add(i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user