Lottó program
This commit is contained in:
25
Lotto/Lotto.sln
Normal file
25
Lotto/Lotto.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35222.181
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lotto", "Lotto\Lotto.csproj", "{75382F57-5116-417B-BAC2-C415BB6E57D7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{75382F57-5116-417B-BAC2-C415BB6E57D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{75382F57-5116-417B-BAC2-C415BB6E57D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{75382F57-5116-417B-BAC2-C415BB6E57D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{75382F57-5116-417B-BAC2-C415BB6E57D7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {65052F96-454B-4D0D-A84D-B7A965AF3080}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
10
Lotto/Lotto/Lotto.csproj
Normal file
10
Lotto/Lotto/Lotto.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>
|
||||
77
Lotto/Lotto/Program.cs
Normal file
77
Lotto/Lotto/Program.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
namespace Lotto
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Lottó");
|
||||
int hanySzam = 0;
|
||||
int mennyiBol = 0;
|
||||
int talalatok = 0;
|
||||
|
||||
Console.Write("Hány számot húzunk?");
|
||||
hanySzam = Convert.ToInt32(Console.ReadLine());
|
||||
Console.Write("Hány számból sorsolunk?");
|
||||
mennyiBol = Convert.ToInt32(Console.ReadLine());
|
||||
Random random = new Random();
|
||||
|
||||
int[] tippek = new int[hanySzam];
|
||||
int[] nyeroszamok = new int[hanySzam];
|
||||
|
||||
//Tippek bekérése
|
||||
//1 és hanySzam között kell lennie
|
||||
//Nem lehet a tippek között
|
||||
|
||||
for (int i = 0; i < hanySzam; i++)
|
||||
{
|
||||
Console.Write($"{i + 1}.tipp:");
|
||||
int temp = Convert.ToInt32(Console.ReadLine());
|
||||
//Ellenőrzés
|
||||
while (temp < 1 || temp > mennyiBol || tippek.Contains(temp))
|
||||
{
|
||||
Console.Write($"Rossz tipp! Újra! {i + 1}.tipp:");
|
||||
temp = Convert.ToInt32(Console.ReadLine());
|
||||
}
|
||||
tippek[i] = temp;
|
||||
}
|
||||
Array.Sort(tippek);
|
||||
Tomblista(tippek);
|
||||
|
||||
//Nyerőszámok sorsolása
|
||||
for (int i = 0; i < hanySzam; i++)
|
||||
{
|
||||
int temp = random.Next(1,mennyiBol+1);
|
||||
while (nyeroszamok.Contains(temp))
|
||||
{
|
||||
temp = random.Next(1, mennyiBol + 1);
|
||||
}
|
||||
nyeroszamok[i] = temp;
|
||||
}
|
||||
Array.Sort(nyeroszamok);
|
||||
Tomblista(nyeroszamok);
|
||||
//Találatok meghatározása
|
||||
for (int i = 0; i < tippek.Length; i++)
|
||||
{
|
||||
for (int j = 0; j < nyeroszamok.Length; j++)
|
||||
{
|
||||
if (tippek[i] == nyeroszamok[j])
|
||||
{
|
||||
talalatok++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"Találatok száma:{talalatok}");
|
||||
|
||||
}
|
||||
|
||||
private static void Tomblista(int[] tomb)
|
||||
{
|
||||
for (int i = 0; i < tomb.Length; i++)
|
||||
{
|
||||
Console.Write(tomb[i] + " ");
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user