当前位置: 首页 > news >正文

牛客:HJ20 密码验证合格程序[华为机考][字符串]

学习要点

  1. 利用容器本身的功能来为解题提供服务
  2. string.find
  3. string.substr
  4. 范围for
  5. string::npos

题目链接

        密码验证合格程序_牛客题霸_牛客网

题目描述

解法:字符串操作

#include <bits/stdc++.h>
#include <cctype>
#include <iostream>
using namespace std;int main() {// 接收字符串vector<string> my_print;string line_str;while(getline(cin,line_str)){bool X = false; bool x = false; bool number = false; bool ch = false;int n = line_str.size();if(n < 8){my_print.push_back("NG");continue;}for(auto &i:line_str){if(islower(i)){x = true;}else if(isupper(i)){X = true;}else if(i>='0' && i<='9'){number = true;}else {ch = true;}}int count =0;if(X) count++;if(x) count++;if(number) count++;if(ch) count++;if(count <3){my_print.push_back("NG");continue;}for(int i =0;i<n;i++){if((i+4) >= n){my_print.push_back("OK");break;}string tmp_str = line_str.substr(i,3);int pos = line_str.find(tmp_str,i+3);if(pos != string::npos){my_print.push_back("NG");// cout << 1 << endl;break;}}}for(auto& str:my_print){cout << str << endl;}}
// 64 位输出请用 printf("%lld")


文章转载自:
http://boxy.hyyxsc.cn
http://abortive.hyyxsc.cn
http://actorish.hyyxsc.cn
http://cerebrocentric.hyyxsc.cn
http://bisk.hyyxsc.cn
http://agglutinogen.hyyxsc.cn
http://bun.hyyxsc.cn
http://brushhook.hyyxsc.cn
http://bole.hyyxsc.cn
http://cad.hyyxsc.cn
http://acquiescent.hyyxsc.cn
http://athematic.hyyxsc.cn
http://cgi.hyyxsc.cn
http://antitype.hyyxsc.cn
http://bieerhaus.hyyxsc.cn
http://champaign.hyyxsc.cn
http://adultery.hyyxsc.cn
http://carinate.hyyxsc.cn
http://bashfully.hyyxsc.cn
http://bacteriophage.hyyxsc.cn
http://bokhara.hyyxsc.cn
http://arhythmic.hyyxsc.cn
http://brickie.hyyxsc.cn
http://barostat.hyyxsc.cn
http://amberoid.hyyxsc.cn
http://atonalistic.hyyxsc.cn
http://chasmic.hyyxsc.cn
http://bazooka.hyyxsc.cn
http://cer.hyyxsc.cn
http://aicpa.hyyxsc.cn
http://www.dtcms.com/a/280696.html

相关文章:

  • 【源力觉醒 创作者计划】文心4.5 vs DeepSeek vs Qwen 3.0:三大能力硬核实测!谁才是王者?
  • 纸板加工制造学习1
  • CF37E Trial for Chief 题解
  • 青年科学基金项目答辩PPT模板 | 杰青优青ppt设计制作美化 | WordinPPT
  • uni-app 学习笔记:Vuex 持久化数据
  • 【C++】神奇的AVL树
  • Java单元测试JUnit
  • 使用 Java 获取 PDF 页面信息(页数、尺寸、旋转角度、方向、标签与边框)
  • 已知均数与标准差,如何生成一组正态分布数据?
  • EPLAN 电气制图(九):直流电源绘制+端子排绘制
  • 线程(二) linux 互斥
  • JVM——有哪些常见的垃圾收集器
  • Props
  • 时序数据库与AI的融合:智能时代的数据基石
  • 027_国际化与本地化
  • Spring应用抛出NoHandlerFoundException、全局异常处理、日志级别
  • FreeRTOS学习笔记——移植说明、任务创建
  • 【Ubuntu22.04】repo安装方法
  • Linux715 磁盘管理:逻辑卷
  • 聊聊MySQL中的buffer pool
  • Spring Boot目录变文件夹?3步解决!
  • Unity Editor下拉框,支持搜索,多层级
  • BGP服务器和多线服务器的不同之处
  • Python初学者笔记第十三期 -- (常用内置函数)
  • 原点安全签约金网络数科,共建一体化数据安全防护体系
  • Docker 镜像(Image)常用命令总结
  • ASP .NET Core 8结合JWT轻松实现身份验证和授权
  • CMake基础:覆盖项目开发的五大配套工具
  • LLM面试题及讲解 4
  • VSCode同时支持Vue2和Vue3开发的插件指南