Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int countLetters(string s, char c) {
- int r = 0;
- for (int i = 0; i < s.size(); ++i) {
- if (s[i] == c) {
- r++;
- }
- }
- return r;
- }
- int main() {
- cout << countLetters("hello", 'l') << endl;
- }
- //g++ 561py.cpp -o 561py.exe && 561py.exe
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement