MBrendecke icon

Lotto

MBrendecke | PRO | 03/10/16 09:04:48 AM UTC | 0 ⭐ | 355 👁️ | Never ⏰ | []
C# |

540 B

|

None

|

0 👍

/

0 👎

using System;
 
namespace Lotto {
 
  internal class Program {
 
    private static void Main(string[] args) {
      int[] lotto = new int[6];
      const int MIN = 1;
      const int MAX = 50;
 
      Random random = new Random();
 
      for (int i = 0; i < lotto.Length; i++) {
        int rand = random.Next(MIN, MAX);
        for (int j = i - 1; j >= 0; j--) {
          if (lotto[j] == rand) {
            rand = random.Next(MIN, MAX);
            j = i - 1;
          }
        }
        lotto[i] = rand;
      }
    }
  }
}

Comments