Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79c2a9b
commit 34a8adb
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package javaapplication3; | ||
|
||
/** | ||
* @date 30/01/19 | ||
* @author SPREEHA DUTTA | ||
*/ | ||
import java.util.*; | ||
public class naive { | ||
public static void main(String []args) | ||
{ | ||
Scanner sc=new Scanner(System.in); | ||
String s,p;int i,j;String str;int c=0; | ||
s=sc.next(); | ||
System.out.println("Enter pattern "); | ||
p=sc.next(); | ||
for(i=0;i<s.length()-p.length();i++) | ||
{ | ||
str=s.substring(i,i+p.length()); | ||
if(str.equals(p)) | ||
{ | ||
System.out.println(i); c=1; | ||
break; | ||
} | ||
} | ||
if(c==0) | ||
System.out.println("Pattern not found"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters