Thứ Bảy, 4 tháng 12, 2021

OCHU PASCAL

var m,n,x,y,z:longint;
        c:char;
        a,b:array[1..200] of string;
procedure nhap;
var i,j:longint;
begin
        readln(m,n);
        for i:=1 to m do
                readln(a[i]);
        for i:=1 to m do
                readln(b[i]);
end;

procedure lay_thong_tin(s:string);
var i:longint;
       // c:char;
begin
	x:=0;y:=0;
  	for i:=1 to n do
   		if s[i]<>'0' then
       	begin
        		if x=0 then x:=i;
             	if s[i]>='A' then
            	begin
               	c:=s[i];
                 	if y=0 then y:=i;
             	end;
         	end;
    	z:=0;
  	for i:=n downto 1 do
   		if s[i]<>'0' then
        		if z=0 then z:=i;
end;

procedure tim_dap_an(s:string);
var i,j:longint;
begin
	for i:=1 to m do
 	begin
   		if (length(b[i])=z-x+1) and (b[i][y-x+1]=c) then
        	begin
        		for j:=1 to length(b[i]) do
             		s[x+j-1]:=b[i][j];
             	writeln(s);
        	end;
   	end;
end;



procedure giai;
var i:longint;
begin
        for i:=1 to m do
	   begin
         		lay_thong_tin(a[i]);
			tim_dap_an(a[i]);
	   end;
end;

begin
        assign(input,'ochu.inp');reset(input);
        assign(output,'ochu.out');rewrite(output);
        nhap;
        giai;
end.

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.