Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

std::count() in C++ STL

#include<iostream>
#define ll long long
#include<vector>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;

void solve()
{
	string s;
	cin >> s;
	// "#programming#"
	//  result = 2
	//  because # repeat twice
	int result = count(s.begin(), s.end(), '#');
	cout << result << "
";
}

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #STL
ADD COMMENT
Topic
Name
9+8 =