
Patrick B. answered 04/12/21
Math and computer tutor/teacher
using namespace std;
#include <iostream>
#include <ctype.h>
#include <string.h>
#define PW_SIZE (3)
Go()
{
char pw[PW_SIZE];
char specialChars[]="~`@#$%^&*()_-+={}[]|\\:;\"\'<>,.?/";
int nChars = strlen(specialChars);
cout << "Please input the password :>";
cin >> pw;
bool charFlag=false;
bool digitFlag=false;
for (int iLoop=0; iLoop<PW_SIZE; iLoop++)
{
char curChar = pw[iLoop];
if (!digitFlag) { digitFlag = isdigit(curChar); }
if (!charFlag) { charFlag = ispunct(curChar); }
for (int jLoop=0; jLoop<nChars; jLoop++)
{
if (curChar==specialChars[jLoop])
{
if (!charFlag)
{
charFlag=true;
}
} //character is a special char
} //for jLoop
} //for iLoop
if (charFlag && digitFlag)
{
cout << "YES " << endl;
}
else
{
cout << "NO " << endl;
}
}
int main()
{
Go();
}