AKB Forums

Go Back   AKB Forums > Technical sections > Algorithms
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Algorithms The source of algorithms for your project

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old May 3, 2002, 21:48   #1
Школьник
 
Join Date: Apr 2002
Location: Vanadzor
Posts: 227
Rep Power: 7
Reputation: 10
Post Rekursiv funkcia

hi,
pojalusta raskajite ne mnojko kak realisuetsya rekursivnaya funkcianaprimer v C++ ili PHP ili chto to vrode etovo.
strax. is offline   Reply With Quote Quote selected
Old May 3, 2002, 22:34   #2
»
 
z0mbie's Avatar
 
Join Date: Jan 2002
Posts: 776
Rep Power: 7
Reputation: 10
Send a message via ICQ to z0mbie
Post

если я правильно понял вопрос то вот пример:

float power( float number,int n)
{
if(n==1) return number; //число в степени 1 это само число
return number*power(number,n-1);
}

для того чтоб получить число в степени n умножаем число на себя в степени n-1.А чтобы получить степень n-1 умножаем степень n-2 на то же число.И так до теx пор пока n-... не будет 1, в этом случае функция себя не вызовет.
z0mbie is offline   Reply With Quote Quote selected
Old May 3, 2002, 23:25   #3
Школьник
 
Join Date: Apr 2002
Location: Vanadzor
Posts: 227
Rep Power: 7
Reputation: 10
Post

che zombie jan, et es gitem , es tenc factorial el em hashvel, xanoyski bashnyaneri xndirn el em lu&el...

indz hetakrkir a te inch eghanakov a realizacvum da henc kompilyatri koghmic.
strax. is offline   Reply With Quote Quote selected
Old May 4, 2002, 01:00   #4
Младенец
 
Join Date: Oct 2001
Location: Yerevan
Posts: 41
Rep Power: 0
Reputation: 10
Post

katarvuma henc nuyn dzevi...
motavorapes senc...

push N
push number
call POWER
....
.......
POWER:
pop ecx
pop eax
cmp eax, 1
jz THAS_IT
mov edx, eax
dec edx
push edx
push ecx
call POWER
mov ecx, eax
dec ecx
mul ecx
THATS_IT:
mov eax, ecx
ret

voncvor te chisht em grel ::}
__________________
http://freenet.am/~softland
SMoKE is offline   Reply With Quote Quote selected
Old May 4, 2002, 07:04   #5
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: Jan 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,166
Rep Power: 7
Reputation: 34
Post

Quote:
Originally posted by strax.:
indz hetakrkir a te inch eghanakov a realizacvum da henc kompilyatri koghmic.
да абсолютно тем же способом, как и вызовы остальных функций. никакой разницы - ни принципиальной, ни в реализации.
Aram Hambardzumyan is offline   Reply With Quote Quote selected
Old May 4, 2002, 16:53   #6
Школьник
 
Join Date: Apr 2002
Location: Vanadzor
Posts: 227
Rep Power: 7
Reputation: 10
Post

ok, thanks

aysinkn amen kanchman jamanak noric chi steghcvum et funkcian, ayl kirakvum a hin@ ` nor parametrnerov.
strax. is offline   Reply With Quote Quote selected
Old May 4, 2002, 17:49   #7
Младенец
 
Join Date: Oct 2001
Location: Yerevan
Posts: 41
Rep Power: 0
Reputation: 10
Post

ayo, nenak petqa hishel vor amen angam funkcian kanchelu depqum parametrera push arvum stack, naev pusha arvum hascen voertexic vor call arvum, vor heto het gal lini, aysinqn ka stack lcvelu problem@ naev ::}
__________________
http://freenet.am/~softland
SMoKE is offline   Reply With Quote Quote selected
Old May 4, 2002, 20:28   #8
Школьник
 
Join Date: Apr 2002
Location: Vanadzor
Posts: 227
Rep Power: 7
Reputation: 10
Post

Quote:
ayo, nenak petqa hishel vor amen angam funkcian kanchelu depqum parametrera push arvum stack, naev pusha arvum hascen voertexic vor call arvum, vor heto het gal lini, aysinqn ka stack lcvelu problem@ naev ::}
ay henc et ei uzum imanam. Aysinkn ete funkcian, mi kich shat gorcghutyun a anum u rekursiv kancher@ shat en, anpayman kkaxvi cragir@...
strax. is offline   Reply With Quote Quote selected
Old May 5, 2002, 02:27   #9
Младенец
 
Join Date: Oct 2001
Location: Yerevan
Posts: 41
Rep Power: 0
Reputation: 10
Post

@ndhanur depqum ha, de et el (stack-i chap@) galisa arden comp-ic, nra RAM-ic ev ayln...
kam el ete chem sxalvum mek-mek el kaxvaca henc cragric te cragir ir hamar inchqan texa vercnum stack-ic
__________________
http://freenet.am/~softland
SMoKE is offline   Reply With Quote Quote selected
Old May 5, 2002, 19:13   #10
Школьник
 
Join Date: Apr 2002
Location: Vanadzor
Posts: 227
Rep Power: 7
Reputation: 10
Post

thanks alot.
strax. is offline   Reply With Quote Quote selected
Old May 6, 2002, 18:49   #11
Administrator
 
greka's Avatar
 
Join Date: Sep 2001
Location: @work
Posts: 5,337
Rep Power: 10
Reputation: 23
Send a message via ICQ to greka
Post

>..steghcvum et funkcian..

Уважаемые, функция не "создается" - а вызывается.

а при вызове функции стек используется не тока для передачи параметров, но и для выделения места под ее локальные переменные.



b/r
__________________
И повешенные могут качаться в неположенную сторону. /С.Е.Лец/
greka is offline   Reply With Quote Quote selected
Old May 7, 2002, 12:23   #12
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
Post

Quote:
Originally posted by SMoKE:
@ndhanur depqum ha, de et el (stack-i chap@) galisa arden comp-ic, nra RAM-ic ev ayln...
kam el ete chem sxalvum mek-mek el kaxvaca henc cragric te cragir ir hamar inchqan texa vercnum stack-ic
Indz tvuma ches sxalvum, vorovhetev asm ov vor grum enq menq enq che stack i chap@ cragri hamar vercnum..
__________________
[x]-=-[ ]-=-[x]
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Old May 7, 2002, 21:13   #13
Школьник
 
Join Date: Apr 2002
Location: Vanadzor
Posts: 227
Rep Power: 7
Reputation: 10
Post

ha, isk ete asm-ov chenk grum
strax. is offline   Reply With Quote Quote selected
Old May 8, 2002, 03:33   #14
Младенец
 
Join Date: Oct 2001
Location: Yerevan
Posts: 41
Rep Power: 0
Reputation: 10
Post

orinak Delphi-um
Project --> Options --> Memory Sizes (Linker)
karas dnes minstack size, maxstack size, imagebase...
__________________
http://freenet.am/~softland
SMoKE is offline   Reply With Quote Quote selected
Old May 8, 2002, 16:15   #15
Младенец
 
Join Date: Feb 2002
Location: Armenia
Posts: 29
Rep Power: 0
Reputation: 10
Post

Hi All

ete hnaravorutjun ka sahmanapakel stack-i chat@ apa karox eq porcel stacki mej grel aveli shat informacia qan ira hnaravorutjunn e , heto najel te in4 e katarvel , pahel e te vo4 stack uxarkac arajin arjeqner@.

sranov havanabar kparzeq me$ qanakov rekursiaji zhamanak problem klini te vo4.
Koriun is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:44.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link