Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Bai2
- {
- class Program
- {
- static void Main(string[] args)
- {
- while (true)
- {
- string temp = Console.ReadLine();
- if (temp == "-1") break;
- if (validatePassword(temp)) Console.WriteLine("Yes");
- else Console.WriteLine("No");
- }
- }
- static bool checkSymbol(char input)
- {
- string symbol = "!@#$%^&*()";
- foreach (char value in symbol)
- {
- if (value == input) return true;
- }
- return false;
- }
- static bool validatePassword(string n)
- {
- bool haveNumber = false, haveUpper = false, haveLower = false, haveSymbol = false;
- if (n.Length < 8) return false;
- foreach(char value in n)
- {
- if (char.IsNumber(value)) haveNumber = true;
- if (char.IsLower(value)) haveUpper = true;
- if (char.IsUpper(value)) haveLower = true;
- if (checkSymbol(value)) haveSymbol = true;
- }
- if (haveNumber == true && haveUpper == true && haveLower == true && haveSymbol == true) return true;
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement