|
|
вернуться в форумWhy my program wrong in 4 test? give some tests!!! help plz (s menya pivo) var s:string; m:array[-50000..50000]of char; i,min,max,u:longint; begin readln(s); u:=0;min:=90001;max:=-90001; for i:=1 to length(s) do begin if s[i]='<' then dec(u); if u<1 then u:=1; if s[i]='>' then inc(u); if (s[i]<>'>')and(s[i]<>'<') then begin m[u]:=s[i]; if min>u then min:=u; if max<u then max:=u; inc(u); end; end; for i:=min to max do write(m[i]); end. Re: Why my program wrong in 4 test? give some tests!!! help plz (s menya pivo) The length of the screen is 80 symbols! man give test plz. With my mistake! man give test plz. With my mistake! Re: Why my program wrong in 4 test? give some tests!!! help plz (s menya pivo) 1) Use a line long 80 2) Read out symbols Re: man give test plz. With my mistake! Here is a piece of code: ........................................... s, res: string; p, i: integer; readln(s); res:= ''; for i:=1 to 80 do res:= res+' '; p:= 1; for i:=1 to length(s) do begin if s[i]='<' then begin dec(p); if p<1 then p:=1; end else if s[i]='>' then begin inc(p); if p>80 then p:=1; end else begin res[p]:= s[i]; inc(p); if p>80 then p:=1; end; end; write(res); ............................................... Something like that will give U AC. Re: man give test plz. With my mistake! I'm not sure, but I think it is because signs are "(:;-!?.,)" Re: Why my program wrong in 4 test? give some tests!!! help plz (s menya pivo) In my case, the problem was that after writing char out I didn't wrap the cursor back to the beginning. |
|
|