Gamingforce Interactive Forums
85242 35212

Go Back   Exploding Garrmondo Weiner Interactive Swiss Army Penis > Garrmondo Network > Help Desk
Register FAQ GFWiki Community Donate Arcade ChocoJournal Calendar

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.
Closed Thread


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 02:53 AM.


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