Untitled

 avatar
Mohammed
plain_text
a month ago
667 B
2
Indexable
#include<cmath>
#include <iostream>
using namespace std;
bool ch (char p){
    if (p>='A' && p<='Z' || p>='a' && p<='z')
        return true;
    return false;
}
int main() {
    string s;
    getline(cin,s);
    bool st=false,ed=false;
    int count=0;
    for(int i=0;i<s.length();i++) {
        if(ch(s[i])==true && st==false) {
            st=true;
        }else if(ch(s[i])==false && st==true) {
            ed=true;
        }

        //
        if (st==true && i==s.length()-1) {
            ed=true;
        }
        if (st==ed && st==true){
            count++;
            st=ed=false;
        }
    }
    cout<<count<<endl;
}
Leave a Comment