杭电OJ2043 密码

#include   
#include  
#include
#include
using namespace std;



int main()
{
    int n;
    char a[50];
    string str;
    bool flag[4];
    bool flag0;
    while (cin >> n)
    {
        getchar();

        while (n--)
        {
            cin >> str;
            flag0 = false;
            flag[0] = flag[1] = flag[2] = flag[3] = false;
            int len = str.length();
            if (len >= 8 && len <= 16)
                flag0 = true;
            strcpy(a, str.c_str());
            for (int i = 0; i < len; i++)
            {
                if (a[i] >= 'A'&&a[i] <= 'Z')
                {
                    flag[0] = true;
                    continue;
                }
                else if (a[i] >= 'a'&&a[i] <= 'z')
                {
                    flag[1] = true;
                    continue;
                }
                else if (a[i] >= '0'&&a[i] <= '9')
                {
                    flag[2] = true;
                    continue;
                }
                else flag[3] = true;
            }
            int count = 0;
            for (int i = 0; i < 4; i++)
            {
                if (flag[i] == true)
                    count++;
            }
            if (count >= 3&&flag0)
                cout << "YES" << endl;
            else cout << "NO" << endl;

        }
    }
    
}

你可能感兴趣的:(杭电OJ)