Sunday, July 4, 2010

PROGRAM TO PERFORM PATTERN MATCHING(DS)

Buzz It
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
char a[50],b[50];
int m,n,i,j,k=1,ok;
clrscr();
cout<<"enter the first string\n";
gets(a);
cout<<"enter the second string\n";
gets(b);
n=strlen(a);
m=strlen(b);
for(i=0;i<n;i++)
{
for(j=k;j<m;j++)
{
if (b[i]==a[j])
{
ok=1;
k++;
break;
}
else
ok=0;
}}
if(ok==1)
cout<<"success\n";
else
cout<<"not\n";
getch();
}

OUTPUT:
enter the first string
farook
enter the second string
rook
success

0 comments:

Post a Comment