Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program tukangsulap;
- var i,N,Q,x,y,f:longint;
- A,B:array[1..1000] of longint;
- P,K,strin:string;
- procedure swap(var a,b:longint);
- var temp:longint;
- begin
- temp:=a;
- a:=b;
- b:=temp;
- end;
- begin
- readln(N);
- for i:=1 to N do begin
- read(A[i]);
- end;
- readln;
- for i:=1 to N do begin
- read(B[i]);
- end;
- readln;
- read(Q);
- readln;
- for i:=1 to Q do begin
- readln(strin);
- P:=copy(strin,1,1);
- K:=copy(strin,5,1);
- val(copy(strin,3,1),x,f);
- val(copy(strin,7,1),y,f);
- if (P='A') and (K='A') then swap(A[x],A[y]);
- if (P='A') and (K='B') then swap(A[x],B[y]);
- if (P='B') and (K='A') then swap(B[x],A[y]);
- if (P='B') and (K='B') then swap(B[x],B[y]);
- end;
- for i:=1 to N do begin
- write(A[i]);
- if i<N then write(' ') else writeln;
- end;
- for i:=1 to N do begin
- write(B[i]);
- if i<N then write(' ') else writeln;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement