(Gast)
n/a Beiträge
|
Problem mit Vorwärtsdeklaration
21. Nov 2006, 20:31
Hallo,
ich bekomme es nicht hin eine function vorwärts zu deklarieren. kann mir jemand helfen und mir zeigen wo die vorwärtsdeklaration hin muss?
Delphi-Quellcode:
program PT_HUE_4_1;
{$APPTYPE CONSOLE}
uses
SysUtils;
const
Digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
Operators = ['+', '-', '*', '/', '~'];
Neg = '~';
var
PolTerm, AlgTerm: string;
function Negat(s: string): string;
begin
if (s[1] = Neg) and (Length(s) = 2) then
begin
Result := '(-' + s[2] + ')';
end;
end;
function Add(s: string): string;
begin
if (s[2] in Digits) then
begin
//Result := s[2] + '+' + MakeAlg(MyCopy(s, 3, (Length(s) - 3)));
end
else if (s[2] in Operators) then
begin
//Result := MyCopy(s, )
end;
end;
function Sub(s: string): string;
begin
Result := s[2] + '-' + s[3];
end;
function Mult(s: string): string;
begin
Result := s[2] + '*' + s[3];
end;
function Divi(s: string): string;
begin
Result := s[2] + '/' + s[3];
end;
function MyCopy(s: string; Index, Length: Integer): string;
var
i: Integer;
begin
Result := '';
for i := Index to Length do
begin
Result := Result + s[i];
end;
end;
function MyTrim(s: string): string;
var
i: Integer;
begin
Result := '';
for i := 1 to Length(s) do
begin
if (s[i] <> ' ') then
begin
Result := Result + s[i];
end;
end;
end;
function MakeAlg(s: string): string;
begin
if (s[1] in Digits) then
begin
Result := s[1];
Exit;
end;
case s[1] of
'+': Result := Add(s);
'-': Result := Sub(s);
'*': Result := Mult(s);
'/': Result := Divi(s);
end;
end;
begin
Writeln('Geben Sie den Term in polnischer Notation ein!');
Readln(PolTerm);
PolTerm := MyTrim(PolTerm);
if (PolTerm <> '') then
begin
AlgTerm := MakeAlg(PolTerm);
Writeln(AlgTerm);
end;
Readln;
Readln;
Readln;
end.
|
|
Zitat
|