Answer the question
In order to leave comments, you need to log in
Why doesn't the Pascal program work?
type list=^point;
point=record
data: char;
next: list;
end;
procedure readList(var L: list);
var c: char;
temp: list;
begin
new(temp);
read (c);
temp^.data:=c;
temp^.next:=nil;
L:=temp;
while not eoln do begin
read(c);
read(c);
new (temp^.next);
temp:=temp^.next;
temp^.data:=c;
temp^.next:=nil;
end;
end;
procedure delDouble(var L: list);
var
temp1, temp2: list;
begin
temp1:=L;
temp2:=L^.next;
while temp2<>nil do begin
if temp1^.data<>temp2^.data then begin
temp2:=temp2^.next;
temp1:=temp1^.next;
end
else
temp2:=temp2^.next;
temp1^.next:=temp2;
end;
while L<>nil do begin
write(L^.data, ' ');
L:=L^.next
end;
end;
function numE(E: char; L: list): integer;
var i: integer;
begin
if L^.next<>nil then begin
if L^.data=E then
numE:=1+numE(E, L^.next)
end;
end;
var L1, L2: list;
j: char;
begin
readList(L1);
L2:=L1;
delDouble(L1);
read(j);
numE(j, L2);
end.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question