0分求助!!(C++)
查看原帖
0分求助!!(C++)
1163819
LiXinLong_LXL楼主2024/5/31 22:46
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char s[105];
int ans; 
int num=1,len,flag;
bool have1,have2,have3,have4,f=1;
int main(){
	cin>>s;
	s[strlen(s)]=',';
	for(int i=0;i<=strlen(s);i++){
		//条件1
		if(s[i]>='a' and s[i]<='z') have1=1;
		else if(s[i]>='A' and s[i]<='Z') have2=1;
		else if(s[i]>='0' and s[i]<='9') have3=1;
		else if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$') have4=1;
		else if(s[i]!=',') f=0;
		else{
			bool temp=0;
			//判断是否满足第一个条件 
			//判断是否含有要求的字符 
			if(f==0) temp=1;
			//判断是否满足第二个条件 
			//判断长度 
			if(len<6 or len>12) temp=1;
			//判断是否满足第三个条件  
			ans=have1+have2+have3;
			if(ans<2) temp=1;
			ans+=have4;
			if(ans<3) temp=1;
			//审核
			if(temp==1){
				flag=i+1;
				len=0;
				ans=0;
				f=1;
				have1=0,have2=0,have3=0,have4=0; 
				continue;
			} 
			//输出 
			for(int j=flag;j<i;j++) cout<<s[j];
			cout<<endl;
			//标记 
			flag=i+1;
			len=0;
			ans=0;
			f=1;
			have1=0,have2=0,have3=0,have4=0; 
		}
		len++;
	}
    return 0;
}
2024/5/31 22:46
加载中...