class Program { private static void InitArray() { int[] arr = new int[7]; Random rnd = new Random(); int tmp; for (int i = 0; i < arr.Length; i++) { tmp = rnd.Next(1, 39); while (IsDup(tmp,arr)) { tmp = rnd.Next(1, 39); } arr[i] = tmp; } PrintTheArray(arr); } private static void PrintTheArray(int[] arr) { foreach (var item in arr) { Console.WriteLine(item); } } private static bool IsDup(int tmp, int[] arr) { foreach (var item in arr) { if(item==tmp) { return true; } } return false; } static void Main(string[] args) { //User Input List<int> lista1 = new List<int>(); for (int i = 1; i <= 7; i++) { try { Console.Write("First Number {0}: ", i); int x = Convert.ToInt16(Console.ReadLine()); lista1.Add(x); } catch (Exception ex) { Console.WriteLine("The input number is incorret! It has to be whole number"); Console.WriteLine("Error: {0}", ex.Message); i--; } } Console.WriteLine("\nChoosen Numbers are: "); foreach (int item in lista1) { Console.WriteLine(item); } //Random Number Generator Console.WriteLine("Random Numbers are: "); InitArray(); Console.ReadLine(); }
IF (JAIL IS FULL) MOVE JESSE_JAMES TO DODGE_CITY.
while (condition) { repeat this bit }
do { repeat this bit } while (condition)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)