fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. char a[1000],b[1000];
  6. int t,i,j,k,x;
  7. cin>>t;
  8. k=0;
  9.  
  10. for(i=1; i<=t; i++){
  11. cin>>a>>b;
  12. x=0;
  13. for(j=0; j<strlen(a); j++){
  14. for( ; k<strlen(b); k++){
  15. if(a[j]==b[k]){
  16. x++;
  17. break;
  18. }
  19. }
  20. }
  21. cout<<"Case "<<i<<": "<<x<<endl;
  22. }
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 16056KB
stdin
2
atgca
atcg
abcd
aaa
stdout
Case 1: 3
Case 2: 0