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 |
write(a[n])->writeln(a[n]);In Reply To:为什么格式错误? Posted by:mayakovsky at 2004-09-30 23:33:15 > program shengchengpailie; > type pailie=array[1..1024] of integer; > var m,n,k,d,e:integer;a:pailie; > > procedure Sort(var a:pailie;shou,wei:integer); > var > i,j,s,t:integer; > begin > for i:=shou to wei-1 do > begin > s:=i; > for j:=i+1 to wei do > if a[j]<a[s] then s:=j; > begin > t:=a[s]; > a[s]:=a[i]; > a[i]:=t; > end; > end; > end; > > procedure after(var a:pailie;n:integer); > var i,j,c,b,t,s,l:integer; > begin > b:=1025;j:=0; > for i:=1 to n-1 do > begin > if a[i]<a[i+1] then j:=i; > end; > if (j=0) then > begin > for i:=1 to n do a[i]:=i; > end > else > begin > for i:=j+1 to n do > begin > if (a[i]>a[j]) and (a[i]<b) then begin c:=i;b:=a[i] end; > end; > t:=b;a[c]:=a[j];a[j]:=t; > sort(a,j+1,n) > end; > end; > begin > readln(m); > for d:=1 to m do > begin > read(n,k); > readln; > for e:=1 to n do > read(a[e]); > for e:=1 to k do > after(a,n); > for e:=1 to n-1 do > write(a[e],' '); > write(a[n]) > end; > end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator