Thursday, 1 January 2015

Needle in the haysack (spoj) (solved just by using the c++ string fucntions)

link to question

using namespace std;
int main()
{   int t;
//    scan
    string a,b;
    int f=-1;
        do{//int k=a.length();

The find function returns the first position where the string is found ,
The second parameter allows the substring to be found in the original string after a particular position , and since we want the next substring to be found after the found result , be initialize f with -1 and always search with f+1 ,
if the sunstring is not found , the find function returns -1 .