944,103 Members | Top Members by Rank

Ad:
Sep 11th, 2005
0

Loop stopping short

Expand Post »
Hi everyone!

I have this loop which just wont complete. My code is:

begin
a:=1;
repeat
b:=1;
repeat
write('element ', a, ',', b, ' = ');
readln(mat[a, b]);
b:=b+1;
until b>n;
a:=a+1;
until a>n;
end;


a, b and n are all declared as integers. This is used to enter the elements of a n by n matrix into the program, a being rows and b columns. The application completely shuts downs after I enter the [n, 1] element and I'm going crazy trying to figure out why!

I'm not asking for a "do this" answer, but some pointing in the right direction would be much apreciated.

Pt
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
platinum is offline Offline
6 posts
since Sep 2005
Sep 13th, 2005
0

Re: Loop stopping short

ok, got it!

Because the matrix is a dynamic array, indexes run from 0 through n-1 instead of 1 through n. Adjustment of a and b values fixed this.

Thanks for looking at it.

Pt
Reputation Points: 10
Solved Threads: 0
Newbie Poster
platinum is offline Offline
6 posts
since Sep 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: Client Server Applications
Next Thread in Pascal and Delphi Forum Timeline: Getting a rollover menu in delphi





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC