2
I made a code in pascal that reads two images type pgm and checks if one is contained in the other, but when reading the second image, instead of reading the program simply warns that the type of image is wrong, based on the verifier I did, I do not know what the reason is, because the first image he reads without problems.
Reading procedure:
procedure ler_img(var o:imagem; var l,c,max:longint);
var y,x:longint;
s:string;
begin
read(s);
if s = 'P2' then
begin
read(c,l);
read(max);
for y:=1 to l do
for x:=1 to c do
read(o[y,x]);
end
else
writeln('tipo errado!');
end;
Core programme:
begin
ler_img(imgO,lO,cO,maxO);
ler_img(imgP,lP,cP,maxP);
ocorrencia(imgO,imgP,lO,lP,cO,cP);
writeln('imagem1');
imprimir_imagem(imgO,lO,cO,maxO);
writeln('imagem2');
imprimir_imagem(imgP,lP,cP,maxP);
end.
the reading and printing of the first image occurs normally, but the second image is not read and prints the following
imagem1
P2
3 3
10
1 2 3
4 5 6
7 8 9
imagem2
P2
0 0
0