fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6. int h[26],H[26],jl,sl;
  7. char S[101],J[101];
  8. int hctr=0,Hctr=0,ctr=0;
  9.  
  10. int t,i,j;
  11.  
  12.  
  13. scanf("%d",&t);
  14.  
  15. while(t) {
  16.  
  17. memset(S,0,101*sizeof(char));
  18. memset(J,0,101*sizeof(char));
  19. memset(h,0,sizeof(int)*26);
  20. memset(H,0,sizeof(int)*26);
  21.  
  22. ctr=0;hctr=0,Hctr=0;
  23. scanf("%s",&J);
  24. scanf("%s",&S);
  25.  
  26. for(i=0;J[i]!='\0';i++) {
  27.  
  28. if(J[i]>=65 && J[i]<=90) {
  29. //printf("%c",J[i]);
  30. H[J[i]-65]=1;
  31. }
  32. else if(J[i]>=97 && J[i]<=122)
  33. {
  34. h[J[i]-97]=1;
  35. }
  36. }
  37.  
  38.  
  39. for(i=0;S[i]!='\0';i++) {
  40.  
  41. if(S[i]>=65 && S[i]<=90 && H[(int)(S[i]-65)]==1) {
  42. ctr++;
  43. }
  44.  
  45. else if(S[i]>=97 && S[i]<=122 && h[(int)(S[i]-97)]==1) {
  46. ctr++;
  47. }
  48.  
  49. }
  50.  
  51. printf("%d\n",ctr);
  52. t--;
  53. }
  54.  
  55. return 0;
  56. }
Success #stdin #stdout 0s 3344KB
stdin
4
abc
abcdef
aA
abAZ
aaa
a
what
none
stdout
3
2
1
0