Skip to content

Instantly share code, notes, and snippets.

@RQN
Last active November 11, 2018 16:38
Show Gist options
  • Save RQN/8af49aa34e7105fe957f to your computer and use it in GitHub Desktop.
Save RQN/8af49aa34e7105fe957f to your computer and use it in GitHub Desktop.
重複順列(再帰)
// using System.Collections.Generic;
static IEnumerable<string> Generate(string[] keyword, int length)
{
if (length > 1)
{
foreach (var key in keyword)
{
foreach (var key2 in Generate(keyword, length - 1))
{
yield return key + key2;
}
}
}
else
{
foreach (var key in keyword)
{
yield return key;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment