Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int buscar (string a, string b)
- {
- int tamA = a.size();
- int tamB = b.size();
- if (tamA>tamB)
- return 0;
- int cant = 0;
- bool hay;
- for (int i=0; i<=tamB-tamA; i++)
- {
- hay = true;
- for(int j=0; j<tamA; j++)
- if (a[j] != b[i+j] )
- hay = false;
- if (hay)
- cant++;
- }
- return cant;
- }
- int main ()
- {
- int L, Q;
- cin>>L;
- vector <string> lista (L);
- for (int i=0; i<L; i++)
- cin>>lista[i];
- cin>>Q;
- vector <string> sub(Q);
- vector <int> resp(Q, 0);
- for (int i=0; i<Q; i++)
- cin>>sub[i];
- for (int i=0; i<Q; i++)
- {
- for (int j=0; j<L; j++)
- resp[i] += buscar( sub[i], lista[j] );
- cout<<resp[i]<<endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment