tuki2501

bai2.cpp

Mar 1st, 2021
645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.   string s; char c;
  6.   cout << "Nhap s: "; getline(cin, s);
  7.   cout << "Nhap c: "; cin >> c;
  8.   int cnt = 0;
  9.   for (int i = 0; i < s.size(); i++) {
  10.     if (s[i] == c) cnt++;
  11.   }
  12.   cout << "So ky tu c trong xau s: " << cnt << '\n';
  13. }
  14.  
Advertisement
Add Comment
Please, Sign In to add comment