Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace RandNumbers
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Random randGen = new Random();
- int[] array2Mix = new int[26];
- for (int i = 0; i < array2Mix.Length; i++)
- {
- array2Mix[i] = i;
- }
- int[] resultArray = new int[array2Mix.Length];
- int randNumber = 0;
- List<int> alreadyGenerated = new List<int>();
- for (int i = 0; i < array2Mix.Length; i++)
- {
- do
- {
- randNumber = randGen.Next(0, array2Mix.Length);
- } while ( alreadyGenerated.Contains(randNumber));
- alreadyGenerated.Add(randNumber);
- resultArray[i] = array2Mix[randNumber];
- Console.WriteLine("{0,3:000}", array2Mix[randNumber]);
- }
- // check if all numbers from 0 to 25 are there in the array
- bool isFound = false;
- int? foundAtPosition = null;
- for (int i = 0; i < array2Mix.Length; i++)
- {
- isFound = false;
- foundAtPosition = null;
- for (int j = 0; j < resultArray.Length; j++)
- {
- if (array2Mix[i] == resultArray[j])
- {
- isFound = true;
- foundAtPosition = j;
- break;
- }
- }
- if (foundAtPosition != null)
- {
- Console.WriteLine($"array2Mix[{i}] = {array2Mix[i]} found at position {foundAtPosition}");
- }
- else
- {
- Console.WriteLine($"array2Mix[{i}] = {array2Mix[i]} NOT FOUND");
- }
- }
- }
- }
- }
- /*
- Use with combination with Excel
- The tasks in the second column. The generated numbers in the first column and sort them by first column. The tasks will be mixed
- For faculty numbers in Excel use format 00#
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement