Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main(){
  4.  
  5. FILE *a;
  6. a = fopen("testdata.in","r");
  7. int test;
  8. char kalimat[105];
  9. int repeat;
  10. char a[105],b[105];
  11. char temp1[105];
  12. char temp2[105];
  13. int length;
  14. int flag;
  15. int result[26]={0};
  16.  
  17. fscanf(a,"%d",&test);
  18.  
  19. for (int i = 0 ; i<test;i++){
  20. flag = 1;
  21. fscanf(a,"%s",kalimat);
  22. length = strlen(kalimat);
  23. fscanf(a,"%d",&repeat);
  24.  
  25. for(int j = 0 ; j<repeat;j++){
  26. fscanf(a,"%s %s",temp1,temp2);
  27. for (int h = 0 ; h<repeat;h++){
  28. if(temp1[0]==a[h]){
  29. flag = 0;
  30. }
  31. }
  32. if(flag==1){
  33. a[j]=temp1[0];
  34. b[j]=temp2[0];
  35. }
  36.  
  37.  
  38. }
  39. for (int j = 0 ; j<length; j++){
  40. for (int h = 0 ; h<repeat;h++){
  41. if(kalimat[j]==a[h]){
  42. kalimat[j]=b[h];
  43. }
  44. }
  45. }
  46.  
  47. for (int j = 0;j<length;j++){
  48.  
  49. if(kalimat[j]>='A'&& kalimat[j]<='Z'){
  50. int value = kalimat[j]-'A';
  51. result[value]++;
  52. }
  53. }
  54.  
  55. for(int j = 0;j<25;j++){
  56. if(result[j]>0){
  57. printf("%c %d\n",j+'A',result[j]);
  58. }
  59. }
  60.  
  61.  
  62. // for (int j = 1 ; j<repeat;j++){
  63. // a[0]==temp;
  64. // if (a[j]==temp){
  65. // a[j]=='\0';
  66. // }
  67. //
  68. // }
  69.  
  70.  
  71.  
  72. }
  73. fclose (a);
  74. return 0 ;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement