473,473 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Converting Pascal to C#

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[i],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
Nov 16 '05 #1
3 9827
What part of "Reproduction in part or in total prohibited by Lower
Saxonian and international law" are we not supposed to pay
attention to?

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/


"Mark Scott" <m@rk******@8lu3y0nd3r.c0.uk> wrote in message
news:SP******************@fe1.news.blueyonder.co.u k...
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[i],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

Nov 16 '05 #2
LOL

Dumbass.

If you are stealing code, at least do it well.

BTW, stealing source is in no way different from stealing a couple of
manufacturingrobots. It is easier, true, but it still is theft.

Kind regards

Alexander

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:OV*************@TK2MSFTNGP12.phx.gbl...
What part of "Reproduction in part or in total prohibited by Lower
Saxonian and international law" are we not supposed to pay
attention to?

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/


"Mark Scott" <m@rk******@8lu3y0nd3r.c0.uk> wrote in message
news:SP******************@fe1.news.blueyonder.co.u k...
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[i],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


Nov 16 '05 #3
This is a direct translation of the pascal as the equivalent c# Console program

using System;

namespace Anagram
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Anagram
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string w;
if (args.Length == 0)
{
Console.Write("Word: ");
w = Console.ReadLine();
}
else
w = args[0];
Perm("", w);
}
static void Perm(string p, string s)
{
if (s.Length == 1)
Console.WriteLine("{0}{1}", p, s);
else
for (int i = 0 ; i < s.Length; i++)
Perm(p + s.Substring(i, 1), RestWord(s, i));
}
static string RestWord(string s, int i)
{
return s.Substring(0, i) + s.Substring(i + 1, s.Length - i - 1);
}
}
}

If you want to make it gui that's up to you

"Mark Scott" wrote:
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[i],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

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris Gordon-Smith | last post by:
I am tying to call a Pascal function from C++, and vice versa. Does anyone know how to do this, or where detailed information on this topic can be found? For the C++ to Pascal call I have...
25
by: TK | last post by:
I'm used to programming in c or c++ in which my problem is simple. I want to be able to enter a value on a page (like 3.2), and then read it as a 32-bit float and break it into it's individual...
28
by: Skybuck Flying | last post by:
Hi, I think I understand now a bit better what the difference is between a c compiler and a pascal compiler. For example: When compiling source code with a pascal compiler. The pascal...
17
by: David Scemama | last post by:
Hi, I'm writing a program using VB.NET that needs to communicate with a DOS Pascal program than cannot be modified. The communication channel is through some file databases, and I have a huge...
0
by: robert | last post by:
I want to convert some algorithms from a Pascal dialect to Python. (Not embedding, but code itself) Its mainly only math and function calls and simple array access but lengthy. Think Pascal is...
15
by: jacob navia | last post by:
Programming languages come and go. Still is amazing that in this survey from http://www.devsource.com/article2/0,1895,2016936,00.asp the C language comes second, right after Java. Java # What...
0
by: dhruba.bandopadhyay | last post by:
Am using Borland C++ 4.5 for the old dos.h APIs. It appears that newer versions of compilers stop support for the oldskool DOS routines. Am trying to convert/port an oldskool Pascal program that...
7
by: SMALLp | last post by:
Hy! I desperately need help! I need to make application that would accept Pascal code and check if it returns good results. My idea is (from a beginner point of view) to make application in...
54
by: Ruud | last post by:
Hallo allemaal, During the conversion of my program from Pascal to C, I was more or less able to find the C equivalent of most Pascal functions so far. Only four gave me some real trouble. I...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.