Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters > Algorithms
Register

Reply
 
LinkBack Thread Tools
Old 03.05.2002, 22:48   #1
Школьник
 
Join Date: 04 2002
Location: Vanadzor
Posts: 227
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post Rekursiv funkcia

hi,
pojalusta raskajite ne mnojko kak realisuetsya rekursivnaya funkcianaprimer v C++ ili PHP ili chto to vrode etovo.
Reply With Quote
Old 03.05.2002, 23:34   #2
»
 
z0mbie's Avatar
 
Join Date: 01 2002
Posts: 777
Downloads: 1
Uploads: 0
Reputation: 0 | 0
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, в этом случае функция себя не вызовет.
Reply With Quote
Old 04.05.2002, 00:25   #3
Школьник
 
Join Date: 04 2002
Location: Vanadzor
Posts: 227
Downloads: 0
Uploads: 0
Reputation: 0 | 0
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.
Reply With Quote
Old 04.05.2002, 02:00   #4
Младенец
 
Join Date: 10 2001
Location: Yerevan
Posts: 55
Downloads: 7
Uploads: 0
Reputation: 8 | 0
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
Reply With Quote
Old 04.05.2002, 08:04   #5
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: 01 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,387
Downloads: 4
Uploads: 0
Reputation: 146 | 4
Post

Quote:
Originally posted by strax.:
indz hetakrkir a te inch eghanakov a realizacvum da henc kompilyatri koghmic.
да абсолютно тем же способом, как и вызовы остальных функций. никакой разницы - ни принципиальной, ни в реализации.
Reply With Quote
Old 04.05.2002, 17:53   #6
Школьник
 
Join Date: 04 2002
Location: Vanadzor
Posts: 227
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

ok, thanks

aysinkn amen kanchman jamanak noric chi steghcvum et funkcian, ayl kirakvum a hin@ ` nor parametrnerov.
Reply With Quote
Old 04.05.2002, 18:49   #7
Младенец
 
Join Date: 10 2001
Location: Yerevan
Posts: 55
Downloads: 7
Uploads: 0
Reputation: 8 | 0
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 ::}
Reply With Quote
Old 04.05.2002, 21:28   #8
Школьник
 
Join Date: 04 2002
Location: Vanadzor
Posts: 227
Downloads: 0
Uploads: 0
Reputation: 0 | 0
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@...
Reply With Quote
Old 05.05.2002, 03:27   #9
Младенец
 
Join Date: 10 2001
Location: Yerevan
Posts: 55
Downloads: 7
Uploads: 0
Reputation: 8 | 0
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
Reply With Quote
Old 05.05.2002, 20:13   #10
Школьник
 
Join Date: 04 2002
Location: Vanadzor
Posts: 227
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

thanks alot.
Reply With Quote
Old 06.05.2002, 19:49   #11
Академик
 
greka's Avatar
 
Join Date: 09 2001
Location: inside myself
Posts: 5,369
Downloads: 0
Uploads: 0
Reputation: 18 | 5
Post

>..steghcvum et funkcian..

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

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



b/r
Reply With Quote
Old 07.05.2002, 13:23   #12
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: 01 2002
Location: hell
Posts: 124
Downloads: 0
Uploads: 0
Reputation: 0 | 0
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..
Reply With Quote
Old 07.05.2002, 22:13   #13
Школьник
 
Join Date: 04 2002
Location: Vanadzor
Posts: 227
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

ha, isk ete asm-ov chenk grum
Reply With Quote
Old 08.05.2002, 04:33   #14
Младенец
 
Join Date: 10 2001
Location: Yerevan
Posts: 55
Downloads: 7
Uploads: 0
Reputation: 8 | 0
Post

orinak Delphi-um
Project --> Options --> Memory Sizes (Linker)
karas dnes minstack size, maxstack size, imagebase...
Reply With Quote
Old 08.05.2002, 17:15   #15
Младенец
 
Join Date: 02 2002
Location: Armenia
Posts: 29
Downloads: 0
Uploads: 0
Reputation: 0 | 0
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.
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 06:04.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.