Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
arranging sorting an array Posted by chineerat on 2 Feb 2010 at 11:46 PM
Hi!
i am having trouble sorting an array using a for loop.
the problem occurs when using iterations i and i+1

for example
count:=0
for i:=0 to count do begin
if a[i] > a[i+1] then begin
....

end
count+1
end

problem is when the for loops reaches the LAST array value i , i+1 does not exist hence the problem.
I have tried using
" for i:=0 to count-1 do begin"
this does not help.

any suggestions?

Thread Tree
chineerat arranging sorting an array on 2 Feb 2010 at 11:46 PM
Atex Re: arranging sorting an array on 3 Feb 2010 at 5:18 PM
chineerat Re: arranging sorting an array on 4 Feb 2010 at 11:47 AM
Atex Re: arranging sorting an array on 4 Feb 2010 at 6:25 PM
chineerat Re: arranging sorting an array on 4 Feb 2010 at 11:50 AM
quikcarl Re: arranging sorting an array on 21 May 2010 at 8:17 PM



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.