M
Mark Scott
I have downloaded some code for a pascal program to generate permutations of
letters to solve anagrams:
program Anagramm;
{ Gibt alle möglichen Anagramme zu einem Wort aus.
Copyright (c) 8/99 by Bastisoft Int'l, Inc.
All rights reserved. Reproduction in part or in total
prohibited by Lower Saxonian and international law. }
var
w : String;
function RestWort(s : String; i : Integer) : String;
begin
RestWort := Copy(s,1,i-1) + Copy(s,i+1,Length(s)-i);
end;
procedure Perm(p, s : String);
var
i : Integer;
begin
if Length(s) = 1 then
Writeln(p,s)
else
for i := 1 to Length(s) do
Perm(p+s,RestWort(s,i));
end;
begin
if ParamCount = 0 then
begin
Write('Wort: ');
Readln(w);
end
else w := ParamStr(1);
Perm('',w);
end.
How would I do this in C#? I have desifned the interface, with an input
text box, and 3 putput buttons, screen, file (to a save as box, text) and
Printer. Any advice would be useful!
Regards
Mark
letters to solve anagrams:
program Anagramm;
{ Gibt alle möglichen Anagramme zu einem Wort aus.
Copyright (c) 8/99 by Bastisoft Int'l, Inc.
All rights reserved. Reproduction in part or in total
prohibited by Lower Saxonian and international law. }
var
w : String;
function RestWort(s : String; i : Integer) : String;
begin
RestWort := Copy(s,1,i-1) + Copy(s,i+1,Length(s)-i);
end;
procedure Perm(p, s : String);
var
i : Integer;
begin
if Length(s) = 1 then
Writeln(p,s)
else
for i := 1 to Length(s) do
Perm(p+s,RestWort(s,i));
end;
begin
if ParamCount = 0 then
begin
Write('Wort: ');
Readln(w);
end
else w := ParamStr(1);
Perm('',w);
end.
How would I do this in C#? I have desifned the interface, with an input
text box, and 3 putput buttons, screen, file (to a save as box, text) and
Printer. Any advice would be useful!
Regards
Mark