Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main(){
  4. int test;
  5. char kalimat[105];
  6. int repeat;
  7. char a[105],b[105];
  8. char temp1[105];
  9. char temp2[105];
  10. int length;
  11. int flag;
  12.  
  13. scanf("%d",&test);
  14.  
  15. for (int i = 0 ; i<test;i++){
  16. flag = 1;
  17. scanf("%s",kalimat);getchar();
  18. length = strlen(kalimat);
  19. scanf("%d",&repeat);getchar();
  20.  
  21. for(int j = 0 ; j<repeat;j++){
  22. scanf("%c %c",&temp1[j],&temp2[j]);
  23. for (int h = 0 ; h<repeat;h++){
  24. if(temp1[0]==a[h]){
  25. flag = 0;
  26. }
  27. }
  28. if(flag==1){
  29. a[j]=temp1[0];
  30. b[j]=temp2[0];
  31. }
  32.  
  33.  
  34. }
  35.  
  36. // for (int j = 1 ; j<repeat;j++){
  37. // a[0]==temp;
  38. // if (a[j]==temp){
  39. // a[j]=='\0';
  40. // }
  41. //
  42. // }
  43. for (int j = 0 ; j<length; j++){
  44. for (int h = 0 ; h<repeat;h++){
  45. if(kalimat[j]==a[h]){
  46. kalimat[j]=b[h];
  47. }
  48. }
  49. }
  50. printf("%s",kalimat);
  51.  
  52.  
  53. }
  54. return 0 ;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement