Advertisement
FLISEN

Untitled

Jan 13th, 2013
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2.  
  3. class Permutations
  4. {
  5.     static void Main()
  6.     {
  7.  
  8.         Console.Write("Enter how long to be the array:");
  9.         int n = int.Parse(Console.ReadLine());
  10.         int[] array = new int[n];
  11.  
  12.         for (int i = 0; i < n; i++)
  13.         {
  14.             array[i] = i + 1;
  15.         }
  16.  
  17.         int temp=0;
  18.        
  19.             for (int j = 0; j < array.Length - 1; j++)
  20.             {
  21.                 for (int k = 0; k < array.Length; k++)
  22.                 {
  23.                    
  24.                     temp = array[j];
  25.                     array[j] = array[k];
  26.                     array[k] = temp;
  27.  
  28.                     for (int p = 0; p < array.Length; p++)
  29.                     {
  30.                         Console.Write(array[p]);
  31.                     }
  32.                     Console.WriteLine();
  33.                 }
  34.             }
  35.  
  36.             for (int j = 0; j < array.Length - 1; j++)
  37.             {
  38.                 for (int k = 0; k < array.Length; k++)
  39.                 {
  40.                     temp = array[j];
  41.                     array[j] = array[k];
  42.                     array[k] = temp;
  43.  
  44.                     for (int p = 0; p < array.Length; p++)
  45.                     {
  46.                         Console.Write(array[p]);
  47.                     }
  48.                     Console.WriteLine();
  49.                 }
  50.             }      
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement