鱼C论坛

 找回密码
 立即注册
查看: 2322|回复: 1

1个点未通过,麻烦大佬看看,有啥缺陷

[复制链接]
发表于 2020-3-26 22:45:48 | 显示全部楼层
所有的输入都保存起来,让所有的输出都在一起看看

  1. #include <iostream>
  2. #include <string>
  3. #include <cctype>

  4. int main()
  5. {
  6.         int num;
  7.         std::cin >> num;
  8.         std::string *s = new std::string[num];
  9.         for(int i = 0; i < num; ++i) std::cin >> s[i];
  10.         for(int i = 0; i < num; ++i) {
  11.                 if(s[i].size() < 6) {
  12.                         std::cout << "Your password is tai duan le." << std::endl;
  13.                         continue;
  14.                 }
  15.                 bool digit = false;
  16.                 bool alpha = false;
  17.                 bool invalid = false;
  18.                 for(const auto j: s[i]) {
  19.                         if(isalpha(j)) alpha = true;
  20.                         else if(isdigit(j)) digit = true;
  21.                         else if(j != '.') {
  22.                                 invalid = true;
  23.                                 break;
  24.                         }
  25.                 }
  26.                 if(invalid) std::cout << "Your password is tai luan le." << std::endl;
  27.                 else if(alpha && !digit) std::cout << "Your password needs shu zi." << std::endl;
  28.                 else if(!alpha && digit) std::cout << "Your password needs zi mu." << std::endl;
  29.                 else std::cout << "Your password is wan mei." << std::endl;

  30.         }
  31.         delete[] s;
  32.         return 0;
  33. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-4-1 20:23

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表