Advertisement
cd62131

count e

Jan 30th, 2014
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int countE(const string &s) {
  5.   int count = 0;
  6.   for (unsigned int i = 0; i < s.size(); i++) {
  7.     if (s.at(i) == 'e') count++;
  8.   }
  9.   return count;
  10. }
  11. int main() {
  12.   vector<string> v = { (string) "aed", (string) "i have a pen", (string) "eeefff" };
  13.   for (string &s: v) {
  14.     cout << s << " " << countE(s) << endl;
  15.   }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement