My code here lists all the permutations of a string
{
public partial class Form1 : Form
{
private int n;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
string scrambledWord = textBox1.Text;
if (e.KeyCode == Keys.Enter)
{
label4.Text = "";
char[] arr = scrambledWord.ToCharArray();
GetPer(arr);
}
}
public void GetPer(char[] list)
{
int x = list.Length - 1;
GetPer(list, 0, x);
}
private void GetPer(char[] list, int k, int m)
{
if (k == m)
{
Console.WriteLine(list);
var text = new string(list);
label4.Text = label4.Text + text + Environment.NewLine;
}
else
for (int i = k; i <= m; i++)
{
Swap(ref list[k], ref list[i]);
GetPer(list, k + 1, m);
Swap(ref list[k], ref list[i]);
}
}
private void Swap(ref char a, ref char b)
{
if (a == b) return;
var temp = a;
a = b;
b = temp;
}
private void label1_TextChanged(object sender, EventArgs e)
{
label4.Height = label4.Height + 10;
}
}
}
Does anyone know how to check if any of the permutations are an English word and the code prints the English words on Visual Studio? Thank you