Advertisement
MrModest

Permutation

Oct 26th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Permutation
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] D;
  14.             List<int> A;
  15.             Console.WriteLine("Enter D:");
  16.             string s = Console.ReadLine();
  17.             Console.WriteLine();
  18.             string[] str = s.Split(' ');
  19.             int N = str.Length;
  20.             D = new int[N];
  21.             A = new List<int>(N);
  22.             for (int i = 0; i < N; i++)
  23.             {
  24.                 D[i] = int.Parse(str[i]);
  25.                 A.Add(i + 1);
  26.                 //Console.WriteLine(" " + D[i] + " " + A[i]);
  27.             }
  28.            
  29.             for(int i = 0; i < N; i++)
  30.             {
  31.                 Console.Write(" " + A[D[i]]);
  32.                 A.RemoveAt(D[i]);
  33.             }
  34.  
  35.             Console.ReadLine();
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement