题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2043

感觉自己读题太不认真啦!

第一次没有考虑密码的长度。欠揍·······

AC代码:

#include <cstdlib>
#include <iostream>
#include <string.h>
using namespace std;

int main(int argc, char *argv[])
{
    int m,len;
    cin>>m;
    char str[50];
    getchar();
    while(m--)
    {
      int sum=0,a=0,b=0,c=0,d=0;
      gets(str);
      len=strlen(str);
      for(int i=0;i<len;i++)
      {
        if(str[i]>='A'&&str[i]<='Z')
          a=1;
        if(str[i]>='0'&&str[i]<='9')
          b=1;
        if(str[i]>='a'&&str[i]<='z')
          c=1;
        if(str[i]=='~'||str[i]=='!'||str[i]=='@'||str[i]=='#'||str[i]=='$'||str[i]=='%'||str[i]=='^')
          d=1;
      }
      sum=a+b+c+d;
      if(sum>=3&&len>=8&&len<=16)
        cout<<"YES"<<endl;
      else
        cout<<"NO"<<endl;
    }
    system("PAUSE");
    return EXIT_SUCCESS;
}

 

相关文章:

  • 2021-10-28
  • 2021-09-02
  • 2021-12-29
  • 2021-04-26
  • 2021-09-01
  • 2021-09-01
  • 2021-09-01
  • 2021-09-01
猜你喜欢
  • 2022-12-23
  • 2022-01-31
  • 2021-09-05
  • 2022-02-04
  • 2021-07-17
  • 2022-02-05
  • 2021-11-05
相关资源
相似解决方案