Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <string>
- using namespace std;
- int main()
- {
- string password;
- bool specialChars = 0, CapitalLetters = 0, smallLetters = 0, Numbers = 0;
- cin>>password;
- if(password.length()>8)
- {
- for(int i = 0; i<password.length(); i++)
- {
- if(!((password[i]<='9' && password[i]>='0') || (password[i]<='Z' && password[i]>='A') || (password[i]<='z' && password[i]>='a')))
- {
- specialChars = true;
- continue;
- }
- if(password[i]<='Z' && password[i]>='A')
- {
- CapitalLetters = true;
- continue;
- }
- if(password[i]<='z' && password[i]>='a')
- {
- smallLetters = true;
- continue;
- }
- if(password[i]<='9' && password[i]>='0')
- {
- Numbers = true;
- continue;
- }
- }
- if(Numbers + smallLetters + CapitalLetters + specialChars == 4)
- {
- cout<<"You have a pretty strong password"<<endl;
- }
- if(Numbers==0)
- {
- cout<<"Your password must contain a number"<<endl;
- }
- if(CapitalLetters==0)
- {
- cout<<"Your password must contain a capital letter"<<endl;
- }
- if(smallLetters==0)
- {
- cout<<"Your password must contain a small letter"<<endl;
- }
- if(specialChars==0)
- {
- cout<<"Your password must contain a special character"<<endl;
- }
- } else
- {
- cout<<"Your password is too short"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement