home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
pascal
/
interpre
/
pl
/
linear.pl
< prev
next >
Wrap
Text File
|
1986-09-24
|
700b
|
39 lines
$ PL Program: Linear Search
begin
const n = 10;
integer array A[n];
integer x,i;
Boolean found;
proc Search
begin
integer m;
i,m:=1,n;
do i<m->
if
A[i] = x -> m:= i;
[]
~(a[I] = x ) -> i:= i + 1;
fi;
od;
found:= (a[i] = x);
end; $ proc search
$ Input Table:
i:= 1;
do
~(i>n) -> read A[i]; i:= i + 1;
od;
$ test search:
read x;
do
~(x = 0)->
call seARCH;
IF
FOUND -> WRITE X, I;
[]
~FOUND -> WRITE x;
fi;
read x;
od;
end.