Question Write a function findpat that takes a long binar
## Question:
## Write a function \"findpat\" that takes a
## long binary pattern in $a0 and a smaller
## binary pattern in $a1, and returns true
## if the long binary pattern contains the
## smaller one.
## For example 100111 base two contains 1001.
##
## Output format must be:
## \"Pattern found\"
Solution
#include<iostream>
using namespace std;
int main()
{ char $a0[100];
char $a1[100];
int count1 = 0, count2 = 0, i, j, flag;
cout << \"Enter a string: \";
cin >> $a0;
cout << \"Enter a string to check if it is substring: \";
cin >> $a1;
while ($a0[count1] != \'\\0\')
count1++;
while ($a1[count2] != \'\\0\')
count2++;
for (i = 0; i <= count1 - count2; i++)
{
for (j = i; j < i + count2; j++)
{
flag = 1;
if ($a0[j] != $a1[j - i])
{
flag = 0;
break;
}
}
if (flag == 1)
break;
}
if (flag == 1)
cout << \"Pattern found!\";
else
cout << \"Pattern not found!\";
}
