|
|
back to boardTest 5. what's wrong?? please help!! Posted by Kirik 22 Feb 2012 16:58 program f; var x,m,i,amount,s,j,g,k:integer; a: array [1..10000] of integer; begin read (m); for i:=1 to m do read (a[i]); for i:=1 to m do begin for j:=1 to m-1 do for g:=1 to m-j do if a[i]>a[i+1] then begin k:=a[i]; a[i]:=a[i+1]; a[i+1]:=k; end; end; amount:=(m div 2) +1; for i:=1 to amount do s:=s+(a[i]div 2)+1; write (s); end. Re: Test 5. what's wrong?? please help!! Posted by tmp 12 Mar 2012 22:56 Incorrect sort algorithm. Variable 's' not initialized. |
|
|