//Naive pattern matching algorithm implementation.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int n,m,s;
clrscr();
char t[200],p[200],count=0;
printf("Enter the data for Naive Pattern Match Algorithm\n");
printf("String: ");scanf("%s",t);
printf("Pattern: ");scanf("%s",p);
n=strlen(t);
m=strlen(p);
printf("Pattern Matched at:");
for(s=0;s<n-m;s++)
{
for(int i=0;i<m;i++)
{
if(t[s+i]==p[i]) count++;
}
if(count==m)
printf("%d\t",s);
count=0;
}
getch();
}
//program written by Mars.
Its better to use gets() instead of scanf() because gets() will consider spaces as well.
ReplyDeleteData Structures
ReplyDeleteSteepest-Ascent Hill Climbing
Forward References | Back-Patching
Transaction State Diagram
Depth Buffer Method / Z-Buffer Method
Algorithm: Single-pass assembler | Intel 8088
Matrix Representation and homogeneous coordinates
Top-Down PDA corresponding to a CFG
ReplyDeleteFeatures of 80386
Data Design
AMP Module
Virtual Mode 80386
Design: Linker
Distributed Operating System Design Issues
Features 80486