File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Java/Algorithms/Searching-Algorithms/BinarySearch Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .util .Scanner ;
2+
3+ public class searching {
4+ public static void main (String [] arhs ) {
5+ Scanner sc = new Scanner (System .in );
6+ System .out .print ("Enter size of array = " );
7+ int n = sc .nextInt ();
8+ String a [] = new String [n ];
9+ String b [] = new String [n ];
10+
11+ System .out .print ("Enter values of A string : " );
12+
13+ for (int k =0 ; k <a .length ; k ++) {
14+ a [k ] = sc .next ();
15+ }
16+ System .out .print ("Enter values of B string : " );
17+ for (int k =0 ; k <b .length ; k ++) {
18+ b [k ] = sc .next ();
19+ }
20+
21+ int result = match (a ,b );
22+
23+ System .out .println (result + " words found to be same" );
24+ }
25+
26+ static int match (String a [], String b []) {
27+ int s =0 ;
28+ for (int i =0 ; i <a .length ; i ++) {
29+ for (int j =0 ; j <b .length ; j ++) {
30+ if (a [i ] == " " )
31+ break ;
32+ else if (a [i ].equals (b [j ]))
33+ s = s +1 ;
34+ }
35+ }
36+ return s ;
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments