|
|
вернуться в форумDo you have any goodidea? Послано Tony 7 окт 2002 11:32 Re: Do you have any goodidea? Послано VladG 13 ноя 2002 10:56 > Just insert numbers to the binary tree and then print them in the order you want. Re: Do you have any goodidea? Послано fk999 1 авг 2003 21:18 > > > rubbish! Re: Do you have any goodidea? Послано PSV 25 мар 2007 21:51 Yeah!! Try to see structure of input and output strings. Resursion-recursion. Re: Do you have any goodidea? program timus1136a; {$APPTYPE CONSOLE} uses SysUtils; const mz=100000; var a,b:array[0..3000] of longint;n,i,p,q:longint; procedure f(u,r,t:longint);begin if(a[u]<r){l} then begin p:=u;exit;end; f(u-1,a[u],t); f(p,r,a[u]); inc(q);b[q]:=a[u];if u<=p then p:=u-1; end; begin read(n); for i := 1 to n do read(a[i]);a[0]:=-1; p:=n;q:=0; f(n,0,mz); for i := 1 to n-1 do write(b[i],' ');write(b[n]);
end. |
|
|