Jump to content
Forum Roportal
Sign in to follow this  
Longint

memoria stivei

Rate this topic

Recommended Posts

estimati necesarul de memorie,determinati valoarea maximala n pentru care programul deruleaza fara erori.

 

program p10;
var n:integer;
function s(n:integer):real;
begin
 if n=0 then s:=0 else s:=s(n-1)+n;
 end;
 begin
readln(n);
writeln('s=',s(n));
readln;

end.

am calculat astfel:

2+6+4=12

2-integer

6-real

4-adresa de revenire

12n -necesarul de memorie

n maximal=1365; 16*1024/12=1365;

dar la executie programul merge pentru n maximal=1320

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×