Gamingforce Interactive Forums
85240 35212

Go Back   Exploding Garrmondo Weiner Interactive Swiss Army Penis > Garrmondo Network > Help Desk

Notices

Welcome to the Exploding Garrmondo Weiner Interactive Swiss Army Penis.
GFF is a community of gaming and music enthusiasts. We have a team of dedicated moderators, constant member-organized activities, and plenty of custom features, including our unique journal system. If this is your first visit, be sure to check out the FAQ or our GFWiki. You will have to register before you can post. Membership is completely free (and gets rid of the pesky advertisement unit underneath this message).


Help with PASCAL and C
Closed Thread
 
Thread Tools
Nagash
I Sell My Heart For Stones


Member 7636

Level 1.10

May 2006


Old Jun 13, 2006, 02:23 PM Local time: Jun 13, 2006, 05:23 PM #1 of 4
Help with PASCAL and C

Hey Guys, i think i NEVER needed so much help from u guys as i need now!

My teacher left me on his classes for 0.3pts, and, he told me to do a algorithm work for these 0.3, and, and i must deliver it TOMORROW (wednesday), what i have to do is, transform a PASCAL algorithm into a C algorithm, but, i know NOTHING of C.... so, if anyone here can PLEASE help me!!!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
01 - Create a NODE on the ROOT in T
-------------
- PASCAL -
-------------
Procedure create_root tvar t: tree; item: Telem);
Var no: tree;
Begin
.new(node);
.no^.esq:nil;
.no^.dir:=nil;
.no^.info=item;
.t:=no;
end;

------
- C -
------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
02 - Verify if the TREE is empty or not. Returns TRUE if it's empty and FALSE if it's full.

-------------
- PASCAL -
-------------
Function Empty(t:tree):boolean;
Begin
.Empty:=(t=nil);
End;

------
- C -
------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
03 - Create a 'SON' on the RIGHT of a given NODE.
- Searches for the element that has Item_Father.
- If Item_Father hasn't a 'SON' on his RIGHT, so, it creates a 'SON' on his RIGHT with its own value.

-------------
- PASCAL -
-------------
Procedure Add_Right(t: tree; item_father, item: Telem)
.Var father,
.......no: tree;
.Begin
..father:=Search(t,item_father);
..if (father<>nil) then
...if (father^.dir<>nil) then
.....erro("This item already has a RIGHT son")
....else
.....begin
.......new(node);
.......no^.left:=nil;
.......no^.right:=nil;
.......no^.info:=item;
.......father^.dir:=node;
.....end;
.end;

------
- C -
------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
04 - Create a 'SON' on the LEFT of a given node.

-------------
- PASCAL -
-------------
Procedure Add_Left(t: tree; item_father, item: Telem)
.Var pai,
.......no: tree;
.Begin
..father:=Search(t,item_father);
..if(father<>nil) then
....if (father^.left<>nil) then
erro("This item already has a son on his LEFT")
else
begin
new(node);
no^.lef:=nil;
no^.right:=nil;
no^.info:=item;
father^.left:=node;
end;
end;

------
- C -
------


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
05 - Verify in which level is a given node.
- Returns the level where a node is.
- If the item won't exists, returns 0 (zero).

-------------
- PASCAL -
-------------
Function Level(t:tree, item:Telem):Integer;
Var n:integer;
.found:boolean;
.Procedure Tresspass(ptr:tree; VAR niv:integer; item:Telem; VAR found:boolean);
...begin
.....IF ptr<>nil then
.........begin
...........niv:=niv+1;
...........IF Equal(ptr^.info, item) then
...............found:=TRUE;
...........ELSE
...............Begin
..................Tresspass(ptr^.left, niv, item, found);
..................If (NOT found) then
.....................Tresspass(ptr^.right, niv, item, found);
..................If (NOT found) then
......................niv:=niv-1;
...............End;
.........End;
...End;
...Begin {Level}
......found:=false;
......n:=0;
......Tresspass(t,n,item, found);
......nivel:=n;
...End;

------
- C -
------


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
06 - Returns the FATHER of a given node.
- Searches for a given ITEM on the tree.
- If YES, returns the value of the father of this node.

-------------
- PASCAL -
-------------
Function Father(t:tree; item:Telem):Telem;
Var found:boolean;
....it:Telem;

Procedure Tresspass(t:tree; item:Telem; var it:Telem; var found:Boolean);
....Begin
........If not Empty(t) Then
............Begin
................If t^.left<>nil then
....................If Equal(item, t^.left^.info) then
........................Begin
............................found:=true;
............................it:=t^.info;
........................End;
................If not found then
....................if t^.right<>nil then
........................if Equal(item, t^.right^.info) then
............................Begin
................................found:=true;
................................it:=t^.info;
............................End;
................If not found then
....................Tresspass(t^.left, item, it, found);
................If not found then
....................Tresspass(t^.dir, item, it, found);
............End;
....End;

....{Tresspass}

....Begin {father}
........if not Emtpy(t) then
............Begin
................found:=false,
................If Equal(item, t^.info) then
....................father:=t^.info; {Father of the root is itself}
................Else
....................Begin
........................Tresspass(t, item, it, found);
........................father:=it;
....................End;
............End;
....End;


------
- C -
------







~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

THX IN ADVANCE GUYS!

Jam it back in, in the dark.
Render
River Chocobo


Member 4283

Level 25.60

Mar 2006


Old Jun 13, 2006, 02:27 PM Local time: Jun 13, 2006, 12:27 PM #2 of 4
lol, homework thread. Shouldv'e done your studying, dude.

ps: no homework threads.

pss: you're screwed!

There's nowhere I can't reach.
Fjordor
Holy Chocobo


Member 97

Level 32.96

Mar 2006


Old Jun 13, 2006, 02:31 PM Local time: Jun 13, 2006, 03:31 PM #3 of 4
Try asking for help in Chocojournal if anything, since obviously you can't post stuff like that here.
Good luck though. I wish I could help, but I have had little exposure to those languages.

Most amazing jew boots
BlueMikey
TREAT?!?


Member 12

Level 35.70

Feb 2006


Old Jun 13, 2006, 08:11 PM Local time: Jun 13, 2006, 06:11 PM #4 of 4
Yeah, closed.

Perhaps you could take the time to, I don't know, learn enough to pass your classes on your own. I mean, this isn't even "I have this small problem, please help", but "Do my entire homework for me!". What the hell is wrong with you? Jesus.

By the way, if your too dumb not to look in any introductory C textbook or Google for this, you're way past anything we can do to help you.

I am a dolphin, do you want me on your body?
and Brandy does her best to understand

Last edited by BlueMikey; Jun 13, 2006 at 10:26 PM.
Closed Thread

Thread Tools

Exploding Garrmondo Weiner Interactive Swiss Army Penis > Garrmondo Network > Help Desk > Help with PASCAL and C

Forum Jump


All times are GMT -5. The time now is 05:15 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2025, vBulletin Solutions, Inc.