Sunday, October 13, 2019

Dimik oj - 14 অক্ষরের ঘনঘটা

#include < bits/stdc++.h >
using namespace std;
int main() {
    int t;
    string s;
    char ch;
    scanf("%d ",&t);
    while(t--) {
        getline(cin , s);
        scanf("%c ",&ch);
        size_t n = count(s.begin(), s.end(), ch);
        if(n > 0){
            cout << "Occurrence of " << "'" << ch <<"'" << " in '" 
<< s << "' = " << n << endl;
        }else {
            cout << "'" << ch << "' is not present" << endl;
        }
    }
    return 0;
}

No comments: