SHARE
TWEET

Untitled

a guest Nov 19th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. /* Define your function here */
  5. int CountCharacters(char userChar, string userString)
  6. {
  7.  int count = 0;
  8.  int size = userString.size();
  9.  for(int i = 0; i < size; i++)
  10.  {
  11.     if(userString.at(i) == userChar)
  12.     {
  13.       count++;  
  14.     }
  15.    
  16.  }
  17.  return count;
  18.    
  19. }
  20. int main() {
  21.    /* Type your code here. Your code must call the function.  */
  22.    char a;
  23.    string b;
  24.    cin >> a >> b;
  25.    cout << CountCharacters(a,b) << endl;
  26.    return 0;
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top