fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define _CRT_SECURE_NO_WARNINGS
  4. char temp[1001][1001]={0};
  5. int main(){
  6. int M,N,T; scanf("%d %d %d", &M, &N, &T);
  7. char arr[1001][1001];
  8. for(int i=0;i<M;i++){
  9. for(int j=0;j<N;j++){
  10. scanf("%s", &arr[i][j]);
  11. }
  12.  
  13. }
  14. int s1[1001],s2[1001];
  15. for(int i=0;i<T;i++){
  16. scanf("%d %d", &s1[i], &s2[i]);
  17. }
  18. for(int j=0;j<M;j++){
  19. memcpy(temp,arr, sizeof(arr));
  20. for(int i=T-1;i>=0;i--){
  21. arr[j][s1[i]]=temp[j][s2[i]];
  22. arr[j][s2[i]]=temp[j][s1[i]];
  23. }
  24. }
  25.  
  26. for(int i=0;i<M;i++){
  27. for(int j=0;j<N;j++){
  28. printf("%c", arr[i][j]);
  29. }
  30. }
  31. printf("\n");
  32. }
Success #stdin #stdout 0s 4180KB
stdin
2 5 3
l l H o e
r l W d o
1 3
2 5
2 4
stdout
lolHrdlW