密码验证合格程序

C/C++编程题之密码验证合格程序 在牛客上刷到密码验证合格程序,现在将通过的代码贴一下,供大家参考。 密码要求: 1.长度超过8位 2.包括大小写字母.数字.其它符号,以上四种至少三种 3.不能有相同长度大于2的子串重复 #include <stdlib.h> #include <stdio.h> #include <string.h> int checklen(char *passwd) { if(strlen(passwd)>8) return 1; 阅读详情

密码验证合格程序

题目描述

密码要求:
1.长度超过8位
2.包括大小写字母.数字.其它符号,以上四种至少三种
3.不能有相同长度超2的子串重复

说明:长度超过2的子串

输入描述:
一组或多组长度超过2的子符串。每组占一行

输出描述:
如果符合要求输出:OK,否则输出NG

示例1
输入
021Abc9000
021Abc9Abc1
021ABC9000
021$bc9000
输出
OK
NG
NG
OK

C++

#include <iostream>
#include <string>
using namespace std;
int main(){
    string str;
    while(cin >> str){
        int flag[4] = {0};
        if(str.size() <= 8) goto NG;
        for(int i = 0; i < str.size(); ++i)
            if(str[i] >= 'a' && str[i] <= 'z') flag[0] = 1;
            else if(str[i] >= 'A' && str[i] <= 'Z') flag[1] = 1;
            else if(str[i] >= '0' && str[i] <= '9') flag[2] = 1;
            else flag[3] = 1;
        if(flag[0] + flag[1] + flag[2] + flag[3] < 3) goto NG;
        for(int i = 0; i <= str.size()-6; i++)
            for(int j = i+3;j < str.size();j++)
                if(str[i] == str[j] && str[i+1] == str[j+1] &&str[i+2] == str[j+2]) goto NG;
        OK:
        cout << "OK" << endl;continue;
        NG:
        cout << "NG" << endl;
    }
    return 0;
}
RPCA模型及GoDec算法 一、基础知识 在线性代数中,秩的物理意义是矩阵中最大的不相关的向量个数,因此秩可以用来度量相关性;而在图像处理中,秩就可以理解为图像中所包含的信息的丰富程度。图片中比较突兀的成分,会增加图像矩阵的秩,一幅清晰的自然图像其数据矩阵往往是低秩或者近似低秩的,这是因为其中的图像信息有很大的相关性,但如果图像中引入噪声,那么存在随机幅值任意大但是分布稀疏的误差破坏了原有数据的低秩性。 低秩矩阵:如果AAA是一个m×nm×nm×n的矩阵,rank(A)rank(A)rank(A)是矩阵AAA的秩,如果rank(A) 阅读详情

相关推荐

电源完整性之Cadence Sigrity Power DC_电热协同仿真

之前和大家分享过电源完整性之仿真设计原理链接: link.今天接着上一篇文章总结一下电源直流压降的的仿真操作流程及一些simulation中的设置参数,用到的是Cadence Sigrity 中的Power DC组件,来操作一下电热协同仿真,下面开始享受仿真的快乐吧: 第0步:仿真简介 电热协同仿真把电和热相互的影响考虑到了一起。因为电导率并不是固定不变的,而是和温度有关,随着温度的升高导电率会下降。同样电流流径电阻的时候会产生热量,此热量为焦耳热。因此为了获得准确的仿真信息,应考虑电与热的互相影响,进行电

刘小同学的博客 1万+

用C语言写一个密码锁

程序使用strcmp函数来比较用户输入的密码和预设的正确密码。这个原理用于验证用户输入的密码是否与正确的密码匹配。:虽然这个程序很简单,但它也引入了一些基本的安全性和限制措施,比如限制尝试次数,以防止暴力破解。在实际应用中,密码应该以加密的形式存储,并且使用更复杂的安全措施来保护密码。:程序使用if-else语句来进行条件分支,根据用户输入的密码是否正确来执行不同的操作。循环会一直执行,直到用户输入正确的密码或者尝试次数用尽。printf("请输入密码: ");// 比较用户输入的密码和正确的密码。

2401_82610562的博客 1478

保姆级教程:用vxe-grid给管理后台加个「智能筛选」功能(支持模糊搜索/多选/范围查询)

本文提供了一份详细的Vxe-Grid智能筛选功能实现教程。通过自定义筛选器渲染,文章逐步指导开发者为后台管理系统添加支持模糊搜索、多选下拉和数值范围查询的智能筛选功能,并分享了性能优化与移动端适配等实战经验。

weixin_29021291的博客 536

判断一个密码是否有效

/包括数字,大写,小写则有效 否则无效。判断一个密码是否有效。

m0_73645140的博客 274

golang 线上事故

golang 线上事故 最近公司要做大促的一些活动。并且单量,qps持续上涨。之前使用的是django python 语言做的一个服务端。目前已经部署的国家里面最多的国家会有300+个实例。大促期间还可能会增加一个实例数。这么多的实例部署,回滚的时间都会特变长,除了问题也不好定位。并且如此多的一个机器,连接数* 实例数也会导致DB等其他服务扛不住这么大的并发。所以决定上go服务解决性能问题。 ...

lcf枫的博客 1537

Shell编程规范及变量

文章目录一.Shell脚本1.1Shell概述1.2Shell脚本 一.Shell脚本 1.1Shell概述 Shell是Linux系统中开机自动加载的一个特殊程序,它将用户输入的指令,转换成Linux内核可以识别的语言,从而让内核执行调用硬件。 Bash是Linux系统中默认使用shell的程序,它位于/bin/bash。 1.2Shell脚本 将需要执行的命令保存到一个文件中,按照顺序执行,它不需要编译,它是解释型的 ...

夏颜的博客 3675

基于 Arduino 的密码锁设计

本设计基于Arduino Uno开发板,使用串口监视器输入密码,并与预设密码进行比较。正确则通过继电器控制开锁,点亮绿灯,并在8x8点阵屏上显示“对”;错误则在点阵屏上显示“错”,并累计错误次数。三次错误后,蜂鸣器报警,红灯闪烁,并通过errorFlag标志位使程序进入等待按键输入的状态。可在锁定状态下通过按键强制开锁,或通过串口输入特定指令进入密码修改模式。

qq_47233399的博客 1041

多模态变体—ALIGN:高效的图像-文本学习

ALIGN 论文介绍了该模型的关键技术。无人工标注数据:使用互联网数据进行训练,不依赖人工清洗的数据集。高效的对比学习策略:采用大规模图像-文本配对数据,通过对比学习优化嵌入空间。支持零样本(zero-shot)学习:可以在没有专门训练的情况下执行多种任务,如分类、检索等。可扩展性强:ALIGN 采用高效的 CNN 或 Transformer 作为编码器,适用于大规模计算。

Azperk的博客 1218

设计程序,利用KMP算法实现密码锁中的虚位密码的判定

设计程序,利用KMP算法实现密码锁中的虚位密码的判定

今天也要加油呀ʕ ᵔᴥᵔ ʔ 432

基于IC617下Layout XL的使用

基于IC617下Layout XL的使用

weixin_43816759的博客 1万+

Android功耗系列专题理论之十一:高通QCOM平台待机功耗问题分析方法

本文详细介绍了高通QCOM平台待机功耗问题的分析方法。首先强调测试环境标准化的重要性,包括关闭无线功能、日志记录和非必要传感器。重点分析了硬件连接检查、驱动配置验证、电源管理策略优化等关键步骤。文章详细讲解了射频校准、时钟源/中断分析、子系统状态检查等专业技术方法,并提供了具体的命令行操作示例。此外还介绍了外设拆解、外灌电压测试等硬件排查手段,以及功耗分解板、波形分析等高级诊断技术。最后强调了固件版本验证和环境因素测试的必要性,为工程师提供了系统性的功耗问题排查思路。

771

编写一个验证密码的程序。(假设正确密码为:abcd且密码不区分大小写) 若输入正确,显示“欢迎使用!” 若输入错误,显示“密码错误,请重新输入!”,让用户再次输入,当密码错误次数达到3次,则显

#include<stdio.h> #include<string.h> void main() { char s1[5]="abcd"; char s2[5]; int n,i; for(n=1;n<4;n++)//输入次数 { printf("请输入密码:\n"); gets(s2); for(i=0;i<5;i++) { ...

Athy's code land 5427

【LLC快速上手系列】LLC轻载时,死区时间怎么调才对?别再傻傻乱搞了!

死区时间,就是指。如果你死区设得好,就能让开通前 ( V_DS to 0 ),完美实现!

weixin_43199439的博客 1856

HJ20 密码验证合格程序【牛客网】

本文介绍了如何编写一个密码验证合格程序。程序需要满足三个条件:密码长度不少于8位;必须包含大写字母、小写字母、数字、特殊字符中的至少三种;不能存在两个独立的、长度大于2的连续子串完全相同。解题思路包括遍历字符串,统计字符类型数量,并使用哈希表检查子串重复情况。参考代码通过C++实现,时间复杂度为O(∑l_i),空间复杂度为O(max l_i)。程序最终输出“OK”或“NG”表示密码是否合格。

yyh520025的博客 1219

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

牛客_密码验证合格程序

【代码】牛客_密码验证合格程序。

d3y1`5 81_09 158

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

HJ20 密码验证合格程序

前期疑问:未完待续。

晴山の博客 346

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

华为机试—密码验证合格程序

你需要书写一个程序验证给定的密码是否合格。子串子串为从原字符串中,连续的选择一段字符(可以全选、可以不选)得到的新字符串。可见字符集为 ASCII 码在 33 到 126 范围内的可见字符。

rigidwill的博客 864

java-HJ20_密码验证合格程序

java-HJ20 密码验证合格程序。

d3y1`5 81_09 349

【华为机试】 HJ20 密码验证合格程序

更具体地,如果存在两个长度大于 的独立子串 ,使得 ,那么密码不合法。子串为从原字符串中,连续的选择一段字符(可以全选、可以不选)得到的新字符串。您可以参阅下表获得其详细信息(您可能关注的内容是,这其中不包含空格、换行)。本题将会给出 组测试数据,确切数字未知,您需要一直读入直到文件结尾;每组测试数据描述如下:在一行上输入一个长度为 ,由可见字符构成的字符串 ,代表待判断的密码。不能分割出两个独立的、长度大于 的连续子串,使得这两个子串完全相同;若密码合格,输出 ,否则输出。

weixin_45780075的博客 585

编程题 - 密码验证合格程序【JavaScript/Node.js解法】

合格密码要求:长度超过 8位;必须包含大写字母、小写字母、数字、特殊字符中的至少三种;不能分割出两个独立的、长度大于 的连续子串,使得这两个子串完全相同

qq_53002037的博客 871

java密码验证合格程序_密码验证合格程序

importjava.util.*;publicclassMain{publicstaticvoidmain(String[]args){Scannerin=newScanner(System.in);//注意hasNext和hasNextLine的区别while(in.hasNextLine()){//注意while处理多个caseString...

weixin_39857153的博客 257
上一篇: 坐标移动
下一篇: 10.正则表达式匹配
ChenyutingZJU
博客等级 码龄10年 18粉丝 248原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值