Search
 
SCRIPT & CODE EXAMPLE
 

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;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to concatenate two vectors in c++ 
Cpp :: cpp auto 
Cpp :: count number of prime numbers in a given range in c 
Cpp :: array of Methods c++ 
Cpp :: vector of vectors of pairs c++ 
Cpp :: c++ class template 
Cpp :: how to use a non const function from a const function 
Cpp :: c++ average vector 
Cpp :: long pi in c++ 
Cpp :: c++ integer array 
Cpp :: how to reverse a vector in c++ 
Cpp :: c++ constructor call superclass 
Cpp :: c++ insert variable into string 
Cpp :: c++ find index of element in array 
Cpp :: c++ uint8_t header 
Cpp :: loop c++ 
Cpp :: max pooling in c++ 
Cpp :: c++ get data type 
Cpp :: adding variables c++ 
Cpp :: even and odd in c++ 
Cpp :: nullptr c++ 
Cpp :: closing a ifstream file c++ 
Cpp :: maximum subarray leetcode c++ 
Cpp :: evennumbers 1 to 100 
Cpp :: c++ string to char* 
Cpp :: copy constructor for vector c++ 
Cpp :: A Program to check if strings are rotations of each other or not 
Cpp :: c++ itoa 
Cpp :: ue4 c++ switch enum 
Cpp :: c++ include difference between quotes and brackets 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =