Advertisement
MBrendecke

Lotto

Mar 10th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Lotto {
  4.  
  5.   internal class Program {
  6.  
  7.     private static void Main(string[] args) {
  8.       int[] lotto = new int[6];
  9.       const int MIN = 1;
  10.       const int MAX = 50;
  11.  
  12.       Random random = new Random();
  13.  
  14.       for (int i = 0; i < lotto.Length; i++) {
  15.         int rand = random.Next(MIN, MAX);
  16.         for (int j = i - 1; j >= 0; j--) {
  17.           if (lotto[j] == rand) {
  18.             rand = random.Next(MIN, MAX);
  19.             j = i - 1;
  20.           }
  21.         }
  22.         lotto[i] = rand;
  23.       }
  24.     }
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement