Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Couting number of substring occurances in C++
#include<iostream> #include<string> #include<algorithm> using namespace std; int countFreq(string str, string str_to_search) { int count = 0, nPos = str.find(str_to_search, 0); // fist occurrence while (nPos != string::npos) { count++; nPos = str.find(str_to_search, nPos + 1); } cout << count; } int main() { int chars; cin >> chars; string filename, finder; cin >> filename >> finder; countFreq(filename, finder); return 0; }
run
|
edit
|
history
|
help
0
Random Vector Generator
OverloadFunc
NonparaSign
Metodos
star print1
Web Browser History
Palindromo
DSU on tree (http://codeforces.com/contest/600/problem/E)
Test Euler Graph
N Queens problem