const
fi='replace.inp';
fo='replace.out';
Var
n,i,k,e,j:longint; o,y,q:string;
a,c:array[0..100000] of string;
s,d:array[0..100000] of string;
Function replace(ss:ansistring;n:longint):ansistring;
Var
b:array[0..100000] of ansistring;
i,d,j,t:longint;
y,x:ansistring;
Begin
ss:=ss+' ';
y:='';
i:=0;
d:=0;
While i<length(ss) do
Begin
inc(i);
If ss[i]<>' ' then
y:=y+ss[i]
Else
Begin
inc(d);
b[d]:=y;
y:='';
End;
End;
t:=0;
For i:=1 to n do
Begin
For j:=1 to d do
If a[i]=b[j] then
Begin
b[j]:=c[i];
inc(t);
End;
End;
For i:=1 to d do
x:=x+b[i]+' ';
While x[length(x)]=' ' do
delete(x,length(x),1);
replace:=x;
End;
Begin
Assign(input,fi);
reset(input);
Readln(input,n);
For i:=1 to n do
Begin
Read(input,q);
y:='';
e:=0;
q:=q+' ';
For j:=1 to length(q) do
Begin
If q[j]<>' ' then
y:=y+q[j]
Else
Begin
inc(e);
d[e]:=y;
y:='';
End;
end;
a[i]:=d[1];
c[i]:=d[2];
Readln(input);
End;
k:=0;
While not eof(input) do
Begin
inc(k);
Read(input,s[k]);
Readln(input);
End;
Assign(output,fo);
Rewrite(output);
For i:=1 to k do
Begin
Writeln(replace(s[i],n));
End;
Close(input);
Close(output);
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.