2 1 2 3 2 2 2
NO YES
C++ 三个不同的代码
第一个
#include <iostream> #include <cstring> using namespace std; int main() { char a[50]; int m,k1,k2,k3,k4; unsigned i; cin>>m; getchar(); while(m--) { k1=k2=k3=k4=0; cin.getline(a,50); if(strlen(a)<8||strlen(a)>16) cout<<"NO"<<endl; else { for(i=0;i<strlen(a);i++) { if(a[i]>='0'&&a[i]<='9') k1=1; if(a[i]>='a'&&a[i]<='z') k2=1; if(a[i]>='A'&&a[i]<='Z') k3=1; if(a[i]=='~'||a[i]=='!'||a[i]=='@'||a[i]=='#'||a[i]=='$'||a[i]=='%'||a[i]=='^') k4=1; } if(k1+k2+k3+k4>=3) cout<<"YES"<<endl; else cout<<"NO"<<endl; } } return 0; }
第二个
#include <iostream> #include <cstring> using namespace std; int main() { char a[50]; int m,k1,k2,k3,k4; unsigned i; cin>>m; getchar(); while(m--) { k1=k2=k3=k4=0; cin.getline(a,50); if(strlen(a)<8||strlen(a)>16) cout<<"NO"<<endl; else { for(i=0;i<strlen(a);i++) { if(a[i]>='0'&&a[i]<='9') k1=1; if(a[i]>='a'&&a[i]<='z') k2=1; if(a[i]>='A'&&a[i]<='Z') k3=1; if(a[i]=='~'||a[i]=='!'||a[i]=='@'||a[i]=='#'||a[i]=='$'||a[i]=='%'||a[i]=='^') k4=1; } if(k1+k2+k3+k4>=3) cout<<"YES"<<endl; else cout<<"NO"<<endl; } } return 0; }第三个
#include<iostream> using namespace std; int main() { int n,q; char c; cin>>n; getchar(); while(n--) { int e=0,f=0,g=0,h=0; int i=0,sum=0; while((c=getchar())!='\n') { if(c>='0'&&c<='9') e=1; if(c>='a'&&c<='z') f=1; if(c>='A'&&c<='Z') g=1; if(c=='~'||c=='!'||c=='@'||c=='#'||c=='$'||c=='%'||c=='^') h=1; i++; } sum=e+f+g+h; if(i<8||i>16) cout<<"NO"<<endl; else { if(sum>=3) cout<<"YES"<<endl; else cout<<"NO"<<endl; } } return 0; }