Created
December 7, 2012 13:17
-
-
Save ackjake/4233224 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static bool CheckBad(int[] a) | |
{ | |
for (int i = 0; i < a.Length; i++) | |
if (a[i] != i) | |
return false; | |
return true; | |
} | |
if (N >= 2) | |
{ | |
int[] nums = new int[N]; | |
for (int i = 0; i < N; i++) | |
{ | |
nums[i] = i; | |
} | |
do | |
{ | |
Shuffle(nums); | |
} while (CheckBad(nums)); | |
if (true) | |
{ | |
for (int i = 0; i < nums.Length; i++) | |
{ | |
Console.WriteLine("Person #" + (i + 1) + " should buy a gift for Person #" + (nums[i] + 1)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment