Gamingforce Interactive Forums
35876 29819

Go Back   Gamingforce Interactive Forums > Gamingforce Computing > OS and Software
Register FAQ GFWiki Members List Donate Arcade ChocoJournal Mark Forums Read

Welcome to the Gamingforce Interactive Forums.
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
 
LinkBack Thread Tools
I Sell My Heart For Stones


Member 7636

Level 1.10

May 2006


Old Jun 13, 2006, 03:23 PM Local time: Jun 13, 2006, 04:23 PM #1 (permalink) 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!
cherry blossom on blue sky


Member 4283

Level 25.57

Mar 2006


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

ps: no homework threads.

pss: you're screwed!
Banned


Member 97

Level 32.96

Mar 2006


Old Jun 13, 2006, 03:31 PM Local time: Jun 13, 2006, 03:31 PM #3 (permalink) 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.
TREAT?!?


Member 12

Level 35.63

Feb 2006


Old Jun 13, 2006, 09:11 PM Local time: Jun 13, 2006, 06:11 PM #4 (permalink) 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.
and Brandy does her best to understand

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


Thread Tools

Gamingforce Interactive Forums > Gamingforce Computing > OS and Software > Help with PASCAL and C

Forum Jump



All times are GMT -5. The time now is 12:03 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0