Toph Problem Passwords Solution in C++

Problem Link
Toph Problem Passwords Solution in C++
#include<bits/stdc++.h>
using namespace std;
void find_pass(string s)
{
    int cnt=0;
    bool digit=false,lowercase=false,uppercase=false;
    for(int i=0;i<s.size();i++)    
    {
        if(s[i]>=48 && s[i]<=57)   //use ascii code
            digit=true;
        if(s[i]>=65 && s[i]<=90)
            uppercase=true;
        if(s[i]>=97 && s[i]<=122)
            lowercase=true;
        if(digit==true && uppercase==true && lowercase==true)
        {
            cnt++;
            digit=false;
            lowercase=false;
            uppercase=false;
        }
    }
    cout<<cnt<<endl;
}
int main()
{
    string s;
    while(cin>>s)
    {
        find_pass(s);
    }
    return 0;
}

No comments

Theme images by enjoynz. Powered by Blogger.