Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. program tukangsulap;
  2. var i,N,Q,x,y,f:longint;
  3. A,B:array[1..1000] of longint;
  4. P,K,strin:string;
  5.  
  6. procedure swap(var a,b:longint);
  7. var temp:longint;
  8. begin
  9.  
  10. temp:=a;
  11. a:=b;
  12. b:=temp;
  13. end;
  14.  
  15. begin
  16. readln(N);
  17.  
  18. for i:=1 to N do begin
  19. read(A[i]);
  20. end;
  21. readln;
  22. for i:=1 to N do begin
  23. read(B[i]);
  24. end;
  25. readln;
  26. read(Q);
  27. readln;
  28. for i:=1 to Q do begin
  29. readln(strin);
  30. P:=copy(strin,1,1);
  31. K:=copy(strin,5,1);
  32. val(copy(strin,3,1),x,f);
  33. val(copy(strin,7,1),y,f);
  34. if (P='A') and (K='A') then swap(A[x],A[y]);
  35. if (P='A') and (K='B') then swap(A[x],B[y]);
  36. if (P='B') and (K='A') then swap(B[x],A[y]);
  37. if (P='B') and (K='B') then swap(B[x],B[y]);
  38. end;
  39.  
  40. for i:=1 to N do begin
  41. write(A[i]);
  42. if i<N then write(' ') else writeln;
  43. end;
  44. for i:=1 to N do begin
  45. write(B[i]);
  46. if i<N then write(' ') else writeln;
  47. end;
  48. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement