Exploding Garrmondo Weiner Interactive Swiss Army Penis

Exploding Garrmondo Weiner Interactive Swiss Army Penis (http://www.gamingforce.org/forums/index.php)
-   Help Desk (http://www.gamingforce.org/forums/forumdisplay.php?f=36)
-   -   Help with PASCAL and C (http://www.gamingforce.org/forums/showthread.php?t=7549)

Nagash Jun 13, 2006 02:23 PM

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 t:(var 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!

Render Jun 13, 2006 02:27 PM

lol, homework thread. Shouldv'e done your studying, dude.

ps: no homework threads.

pss: you're screwed!

Fjordor Jun 13, 2006 02:31 PM

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.

BlueMikey Jun 13, 2006 08:11 PM

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.


All times are GMT -5. The time now is 09:53 PM.

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