C#-Quellcode
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Lotto
- {
- class _6Aus49
- {
- /* Werte festlegen */
- static int counter = 0;
- static int max_kombinationen = 13983816;
- static int ErsteZahl = 45;
- static int ZweiteZahl = 46;
- static int DritteZahl = 46;
- static int VierteZahl = 48;
- static int FünfteZahl = 49;
- static int SechsteZahl = 50;
- /* Hauptteil des Programmes */
- public static int main()
- {
- Console.Title = "Lotto: 6 Aus 49";
- /* Try-Catch Block */
- try
- {
- for(int a = 1; a < ErsteZahl; a++)
- {
- for(int b = a + 1; b < ZweiteZahl; b++)
- {
- for (int c = b + 1; c < DritteZahl; c++)
- {
- for (int d = c + 1; d < VierteZahl; d++)
- {
- for (int e = d + 1; e < FünfteZahl; e++)
- {
- for (int f = e + 1; f < SechsteZahl; f++)
- {
- counter++;
- Console.WriteLine(a + " " + b + " " + c + " " + d + " " + e + " " + f + " -> " + counter);
- if(counter == max_kombinationen)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine($"Es wurden {counter} Kombinationen wurden erstellt!");
- Console.ReadKey();
- }
- }
- }
- }
- }
- }
- }
- }
- catch(Exception ex)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Fehler: " + ex);
- Console.ReadKey();
- }
- return 0;
- }
- }
- }
Ich habe es jetzt so gemacht erstmal, gibt es aber auch noch eine Möglichkeit das irgendwie anders zu machen?
Habt ihr eine Idee wie ich diesen Code auch anders schreiben könnte?