Posted by Weasel on 1999-04-24
Eugene Teo wrote:
>
> Hi
>
> I am revising for my Advanced Data Structures module
> and i have got 2 important questions to ask. Please
> help.
>
> Question 1:
>
> (a+b(c+7)).
I've written a Pascal unit on this once. You may get it at our coder's
knowledge base:
www.netalive.org/ckb in the pascal/dos/math section. I use a tree
structure to parse it. It may not be that elegant but I did come up with
this myself a few years ago...
> Boolean IsPalindrome(char *s);
Recursive is a studip approach for this one but since you have to do it
this way, I'ld suggest sg like this:
function isPali(string) returns boolean
begin
if firstletter=lastletter
if length(string)=1 return true;
return IsPale(string[1]-string[length-1]); (assuming the string
counts from zero, i.e. you pass the string without the last and without
the first character)
else
return false
end;
end;
--
Weasel mailto:palfrader@xxxxxxx.xxx
Peter http://www.cosy.sbg.ac.at/~ppalfrad/
------------------------------------------------------------
We have full klingon console support just in case.
-- Alan Cox on linux-kernel
Previous post | Next post | Timeline | Home