别人养蛙,我养WA。
查看原帖
别人养蛙,我养WA。
1120678
13288917088c楼主2023/11/27 21:32

样例全过爆0, 求助大牛

#include<bits/stdc++.h>
using namespace std;
bool f(string s){
	long long n=s.size();
	int a,b,c,d,e=(6<n&&n<12);
	/*
	a:大写字母
	b:小写字母
	c:数字
	d:特殊字符
	e:6<长度&&长度<12
	
	本来是bool,但是后面有加法,改成int了。 
	*/
	for(int i=0;i<n;i++){
		if('A'<=s[i]&&s[i]<='Z'){
			a=1;
			continue;
		}
		if('a'<=s[i]&&s[i]<='z'){
			b=1;
			continue;
		}
		if('0'<=s[i]&&s[i]<='9'){
			c=1;
			continue;
		}
		if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$'){
			d=1;
			continue;
		}
		return 0;
	}
	if((a+b+c>=2)&&d&&e){return 1;}
	return 0;
}
int main(){
	string s="",str;
	char x;
	int cnt=0;
	getline(cin,str);
	int n=str.size();
	for(int i=0;i<n;i++){
		x=str[i];
		if(x==','){
			if(f(s)){
				if(cnt){
					cout<<"\n";
				}
				cout<<s;
				cnt++;
			}
			s="";
			continue;
		}
		s.push_back(x);
	}
    return 0;
}
2023/11/27 21:32
加载中...