Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace K_C_Shuffle
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- int[] numbers = new int[10];
- int minValue = 0;
- int maxValue = 9;
- for (int i = 0; i < numbers.Length; i++)
- {
- numbers[i] = random.Next(minValue, maxValue + 1);
- }
- OutputArray(numbers);
- Shuffle(numbers);
- Console.WriteLine();
- OutputArray(numbers);
- }
- static void Shuffle(int[] array)
- {
- Random random = new Random();
- for (int i = 0; i < array.Length; i++)
- {
- int tempIndex = random.Next(array.Length);
- int tempValue = array[tempIndex];
- array[tempIndex] = array[i];
- array[i] = tempValue;
- }
- }
- static void OutputArray (int[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write(array[i]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement