/* * 由SharpDevelop创建。 * 用户: Administrator * 日期: 2018/10/20 * 时间: 15:53 * * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件 */ using System; namespace C密码 { class Program { public static void Main(string[] args) { string str=Console.ReadLine(); if (str.Length>=8&&str.Length <=16) { bool isHaveUpper=false;//大写 bool isHaveLower=false;//小写 bool isHaveNamber=false;//数字 bool isHaveSpecial=false;//符号 for (int i = 0; i < str.Length; i++) { if(str[i]>='A'&&str[i]<='Z'){ isHaveUpper=true ; }if(str[i]>='a'&&str[i]<='z'){ isHaveLower=true ; }if(str[i]>='0'&&str[i]<='9'){ isHaveNamber=true ; }if(str[i]=='~'||str[i]=='!'||str[i]=='@'||str[i]=='#'||str[i]=='$'||str[i]=='%'||str[i]=='^'){ isHaveSpecial=true ; } } int count=0; if(isHaveUpper )count ++; if(isHaveLower )count ++; if(isHaveNamber)count ++; if(isHaveSpecial )count ++; if(count >=3){ Console.WriteLine("这个密码安全 "); } else { Console.WriteLine("这个密码不安全"); } } else { Console.WriteLine("这个密码不安全,长度不符合规则 "); } // TODO: Implement Functionality Here Console.Write("Press any key to continue . . . "); Console.ReadKey(true); } } }