Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Permutations
- {
- static void Main()
- {
- Console.Write("Enter how long to be the array:");
- int n = int.Parse(Console.ReadLine());
- int[] array = new int[n];
- for (int i = 0; i < n; i++)
- {
- array[i] = i + 1;
- }
- int temp=0;
- for (int j = 0; j < array.Length - 1; j++)
- {
- for (int k = j+1; k < array.Length; k++)
- {
- temp = array[j];
- array[j] = array[k];
- array[k] = temp;
- for (int p = 0; p < array.Length; p++)
- {
- Console.Write(array[p]);
- }
- Console.WriteLine();
- }
- }
- for (int j = 0; j < array.Length - 1; j++)
- {
- for (int k = j+1; k < array.Length; k++)
- {
- temp = array[j];
- array[j] = array[k];
- array[k] = temp;
- for (int p = 0; p < array.Length; p++)
- {
- Console.Write(array[p]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement