Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
水题var a:array[1..100000] of longint; n,i:longint; procedure sort(l,r:longint); var i,j,t,x:longint; begin i:=l; j:=r; x:=a[(l+r) div 2]; repeat while a[i]<x do inc(i); while a[j]>x do dec(j); if not(i>j) then begin t:=a[i]; a[i]:=a[j]; a[j]:=t; inc(i); dec(j); end; until i>j; if l<j then sort(l,j); if r>i then sort(i,r); end; begin readln(n); for i:=1 to n do readln(a[i]); sort(1,n); writeln(a[(1+n) div 2]); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator