|
|
back to boardPascal. Who could help me, please? I tried this program, but there was an compilation error: var a,b,c:integer; begin readln(a,b); if a>b then c:=ceil(2*a/b) else c:=2; write(c); end. I understood that, FreePascal doesn't know function ceil(). I described it like this: function ceil(a:real):real; begin if frac(a)=0 then ceil:=a else ceil:=int(a)+1; end; var a,b:integer; c:real; begin readln(a,b); if a>b then c:=ceil(2*a/b) else c:=2; write(c); end. But it doesn't work! First, why? Second, I tried an another code: var n,k,m:integer; begin read(n,k); if n>k then if 2*n mod k=0 then m:=2*n div k else m:=(2*n div k)+1 else m:=2; write(m); end. It works! But I don't understand differences between this program and my first program! Could you help me? Edited by author 23.08.2013 20:31 Re: Pascal. Who could help me, please? The function ceil returns a float. Maybe thats thr problem Sometimes write (c) Writes 3.0 and not 3 as it should Re: Pascal. Who could help me, please? Thanks! |
|
|