Skip to content

Commit 87c42ec

Browse files
author
João Pedro Moisakis
committed
add checkSubstring algorithm in c++
1 parent 1946b4f commit 87c42ec

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

String/Substring/check_substring.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <iostream>
2+
#include <string>
3+
4+
using namespace std;
5+
6+
bool isSubstr(string a, string b){
7+
bool is =0;
8+
if(b.find(a) != std::string::npos){
9+
is =1;
10+
}
11+
return is;
12+
}
13+
//check if string a is substring of b
14+
int main(){
15+
string a,b;
16+
cin >> a;
17+
cin >> b;
18+
19+
if(isSubstr(a,b)){
20+
cout << "yes"<<endl;
21+
}else{
22+
cout << "no"<<endl;
23+
}
24+
25+
26+
return 0;
27+
}

0 commit comments

Comments
 (0)