You are not logged in.
Pages: 1
hi guys
i've been doing my programming homework and i got an error,but don't know where's the problem.
here's the code.it's Pascal and written in Lazarus v0.9.28.2 beta:
program Project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes
{ you can add units after this };
const
k=100;
type
niz=array[1..k] of real;
matrica=array[1..k] of niz;
var
a:matrica;
n,i,j:integer;
procedure exchange(x,y:real);
var p:real;
begin
p:=x;
x:=y;
y:=p;
end;
procedure QuickSort(var a:matrica;var b:niz;levi,desni,n:integer);
var
i,j,k:integer;
D:real;
begin
if levi<desni then
begin
i:=levi;
j:=desni;
D:=b[desni];
repeat
while b[i]<D do
i:=i+1;
while (b[j]>=D) and (i<j) do
j:=j-1;
if i<j then
begin
exchange(b[i],b[j]);
for k:=1 to n do
exchange(a[i][k],a[j][k]);
end;
until i=j;
exchange(b[i],b[desni]);
QuickSort(a,b,levi,i-1,n);
QuickSort(a,b,i+1,desni,n);
end;
end;
procedure GrowingRows(var a:matrica;n:integer);
var
b:niz;
i:integer;
begin
for i:=1 to n do
------------b[i]=a[i][1];------------
QuickSort(a,b,1,n,n);
end;
begin
write('Enter the number of rows of the square matrix: ');
readln(n);
for i:=1 to n do
begin
for j:=1 to n do
read(a[i][j]);
readln;
end;
GrowingRows(a,n);
for i:=1 to n do
for j:=1 to n do
write(a[i][j]);
readln;
end.
i have marked the line in problem and the error message says:'Error: Illegal expression'
Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
Hi anonimnystefy;
Sorry, I do not remember anything about Pascal! It is right they call it Lazarus.
General Advice:
Doesn't it have a built in debugger that allows you to single step through the program? Should also have a variable pane so you can see what is happening statement by statement.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Maybe put in a begin and end around the line, even though you don't need it.
Another possiblility is that you forgot the colon in front of the equal sign...
Last edited by John E. Franklin (2011-09-22 15:19:14)
igloo myrtilles fourmis
Offline
hi guys
thanks,i found the problem 10 minutes after i posted.and it was what JEF said,i was missing a colon in front of the equal sign.
Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
Pages: 1