From 9dd840c36a0182457bbdaac16da492053dac935f Mon Sep 17 00:00:00 2001 From: abee62 <62689173+abee62@users.noreply.github.com> Date: Mon, 19 Oct 2020 11:58:12 +0530 Subject: [PATCH] Added Naive Pattern Searching under String Algorithms in C++ - abee62 --- C++/naive_pattern_searching.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 C++/naive_pattern_searching.cpp diff --git a/C++/naive_pattern_searching.cpp b/C++/naive_pattern_searching.cpp new file mode 100644 index 0000000..c05b72b --- /dev/null +++ b/C++/naive_pattern_searching.cpp @@ -0,0 +1,32 @@ +//naive pattern searching - abee62 +#include +using namespace std; +int main() +{ + char s[1000],pat[1000],flag=0; + cout<<"Enter the complete text in which you want to search\n"; + cin.getline(s,1000); + cout<<"Enter the pattern\n"; + cin.getline(pat,1000); + int a,b; + a=strlen(s); + b=strlen(pat); + for(int i=0;i<=(a-b);i++ ) + { + int j; + for(j=0;j