Hello everyone,
I have to create a Palindrome Programme in Pascal using Pointers and Queues.
A Palindrome is a word which when spelt backwards or forward if the same ex RACECAR or RADAR.
I am having a problem actually creating the Palindrome Part of the Code.
Thus Far, this is what I have
PROGRAM Palindrome (input, output);
TYPE
pQueue = ^tQueue;
tQueue = RECORD
prev : pQueue;
data : String [80];
next : pQueue;
END;
VAR
Front, Rear, Temp : pQueue;
i : String [80];
Choice : CHAR;
Count : INTEGER;
Palid : BOOLEAN;
{***************************************************************************}
PROCEDURE add;
BEGIN
NEW (Temp);
Temp^.data := i;
Temp^.next := nil;
IF Front = nil THEN
Front := Temp
ELSE Rear^.next := Temp;
Rear := Temp;
END;
{***************************************************************************}
PROCEDURE view;
BEGIN
Temp := Front;
WHILE Temp <> Nil DO
BEGIN
WRITELN (Temp^.data);
Temp := Temp^.next;
END;
END;
{***************************************************************************}
PROCEDURE destroy;
BEGIN
Temp := Front;
WHILE Temp <> nil DO
BEGIN
Temp := Temp^.next;
DISPOSE (Front);
Front := Temp;
END;
END;
{***************************************************************************}
PROCEDURE Entry;
BEGIN
Front := Nil;
WRITELN ('Please Enter A Word');
READLN (i);
add;
view;
destroy;
END;
{***************************************************************************}
BEGIN
Count := 0;
WRITELN ('Would You Like To Enter A Word?');
READLN (Choice);
WHILE (Choice = 'Y') OR (Choice = 'y') DO
BEGIN
IF (Choice = 'Y') OR (Choice = 'y') THEN
Entry;
WRITELN ('Would You Like To Enter Another Word?');
READLN (Choice);
Count := Count + 1;
END;
WRITELN (Count);
END.
I am having Problems creating the Palindrome Part. Can anyone help me out here?
I am not allowed to use arrays. Just Queues and Pointers.
Thanking you in adavnce for your assistance.