TEL求调
查看原帖
TEL求调
1393513
C_Spamton楼主2025/1/23 21:29
#include <iostream>
using namespace std;
//
string str[20];
int stri; //字符串数组下标
int strL; //记录密码长度,以验证密码合规性
bool big; //大写字母
bool sam; //小写字母
bool num; //数字
int spc ; //特殊字符
char c;
int main()
{
	while (true){
		cin.get(c);
		if (c == 10)/*是否为末尾*/ {
			return 0;
		}else if (c != ',')/*是否不是逗号*/ {
			if /*字符是否合规*/ ((c >= '0' and c <= '9') or (c >= 'A' and c <= 'Z')
							or (c >='a' and c<='z')
							or (c=='!') or (c=='@') or (c=='#') or (c=='$')){
				//题言“大写字母,小写字母和数字必须至少有其中两种,以及至少有四个特殊字符中的一个”
				if     (c >= '0' and c <= '9') num=1;
				else if(c >= 'A' and c <= 'Z') big=1;
				else if(c >= 'a' and c <= 'z') sam=1;
				else spc=1;
				strL++;//增加密码长度
				str[stri]+=c;
			}
			else/*不合规*/ {
				bool isEnd = false;
				do {/*丢弃这段密码的下半部分*/
					cin.get(c);
					if (c == 10) {
						isEnd = true;
						break;
					}
				} while (c!=',');
				if (isEnd)//末尾
					return 0;
				else /*非末尾*/ {
					str[stri] = "";//清空字符串
					strL = 0;
					big = 0; sam = 0; num = 0; spc = 0;
				}
			}
			
		}else /*逗号*/{
			if ((strL >= 6 and strL <= 12) and (num+sam+big >= 2 and spc >=1))/*检验密码长度、全面性*/ {
				cout << str[stri] << endl;
			}
			strL = 0; big = 0; sam = 0; num = 0; spc = 0;
			stri++;
		}
	}
}
2025/1/23 21:29
加载中...