|
|
вернуться в форумwhy i have crash? type pt=^p; p=record n:longint; next:pt; end; var a:array[1..1000000]of pt; q,t:pt; s:string[4]; n:longint; procedure init; var i,j:longint; begin readln(n); for i:=1 to n do begin read(s); if s='PUSH'then begin new(q); read(j); readln(q^.n); t:=a[j]; a[j]:=q; a[j]^.next:=t; end else begin readln(j); writeln(a[j]^.n); a[j]:=a[j]^.next; end; end; end; begin init; end. Edited by author 15.02.2006 19:11 Because FreePascal reads strings of limited length otherwise than Delphi does (+) I don't have FP, so I can't tell how exactly. Use the following code to get ML 10: {s: string;} c: char ... {read(s);} read(c, c, c, c); {if s='PUSH' then begin} if c='H' then begin ... thank you but i have another problem ML test10 can i dispose q after using it once and then again new(q) I don't have FP, so I can't tell how exactly. Use the following code to get ML 10: {s: string;} c: char ... {read(s);} read(c, c, c, c); {if s='PUSH' then begin} if c='H' then begin ... Edited by author 16.02.2006 16:00You can, but I think it wouldn't help for this problem (+) In fact, it is good style to always dispose everything that you don't need. Edited by author 16.02.2006 18:05 i have tried and got crash again i dont understand why In fact, it is good style to always dispose everything that you don't need. Edited by author 16.02.2006 18:05 Post your code again then :) (-) - Re: DO YOU HAVE ANY IDEA TO DEC IT'S MEMORY type pt=^p; p=record n:longint; next:pt; end; var a:array[1..1000]of pt; q:pt; s:char; n:longint; procedure init; var i,j:longint; begin readln(n); for i:=1 to n do begin read(s,s,s,s); if s='H'then begin new(q); read(j); readln(q^.n); q^.next:=a[j]; a[j]:=q; a[j]^.next:=q^.next; end else begin readln(j); writeln(a[j]^.n); a[j]:=a[j]^.next; end; end; end; begin init; end. I think you need a different approach for this problem (-) - |
|
|