首页 > 其他分享 >华为OD机试 - 密码输入检测 字符串

华为OD机试 - 密码输入检测 字符串

时间:2024-08-21 18:23:06浏览次数:8  
标签:status OD setbit 华为 && 机试 bout include out

只在本地跑过,不确保一定对

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

#define setbit(value,bit) (value = value |(1<<bit))

int main(void)
{
    char buf[201];
    char out[201];
    int i = 0;
    int top = 0;
    int len = 0;
    bool bout = false;
    int status=0;

    while(1)
    {
        top = 0;
        status = 0x00;
        bout = false;
        memset(buf,'\0',sizeof(buf));

        gets(buf);

        len = strlen(buf);//不包含最后结束符\0

        for(i=0; i<len; i++)
        {
            if(buf[i] != '<')
            {
                out[top] = buf[i];
                top++;
            }
            else
            {
                top--;//消掉栈顶
            }
        }

        out[top] = '\0';
        
        if(top>=8)
        {
            setbit(status,0);
            for(i=0; i<top; i++)
            {
                if(out[i]>= 'A' && out[i]<='Z')
                {
                    setbit(status,1);
                    printf("bit1\n");
                }
                else if(out[i]>= 'a' && out[i]<='z')
                {
                    setbit(status,2);
                    printf("bit2\n");
                }
                else if(out[i]>= '0' && out[i]<='9')
                {
                    setbit(status,3);
                    printf("bit3\n");
                }
                else if(out[i] > ' ' )//大于空格后面的字符都是特殊字符
                {
                    setbit(status,4);
                    printf("bit4\n");
                }
            }
        }
        else
        {
            bout = false;
        }

        if((status & 0x1f) == 0x1f)
        {
            bout = true;
        }
        printf("%s,%d 0x%x\n",out,bout,status);
    }
}

标签:status,OD,setbit,华为,&&,机试,bout,include,out
From: https://blog.csdn.net/weixin_39257775/article/details/141400295

相关文章

  • x-cmd mod | x apt - 增强 apt 命令
    目录介绍使用语法例子参数子命令介绍apt模块致力于增强apt用户在命令行的使用体验,它对apt的增强主要有以下几点:提供交互式UI,以便用户更好的搜索和安装软件。提供mirror命令用于管理镜像源,以便用户可以根据情况快捷地更换合适的apt镜像源。提供proxy命......
  • leetcode面试经典150题- 3. 无重复字符的最长子串
    https://leetcode.cn/problems/longest-substring-without-repeating-characters/description/?envType=study-plan-v2&envId=top-interview-150  packageleetcode150import"testing"funcTestLengthOfLongestSubstring(t*testing.T){s:=&qu......
  • 一次Kubernetes Pod内存异常导致的测试环境耗时异常问题排查过程
    概述在使用公司内部后台系统测试环境时发现一个请求加载慢的问题,简简单单的列表,查询MongoDB数据库,测试环境不过几百上千条数据而已,请求耗时居然高达5~6秒:作为对比,生产环境的请求响应截图如下:经过持续跟进,该后台系统所有列表页面测试环境普遍比生产环境慢,不管是MongoDB还是MyS......
  • 记一次Kotlin Visibility Modifiers引发的问题
    概述测试环境爆出ERROR告警日志java.lang.IllegalStateException:Didn'tfindreportforspecifiedlanguage,登录测试环境ELK查到如下具体的报错堆栈日志:java.lang.IllegalStateException:Didn'tfindreportforspecifiedlanguageatcom.aba.report.service.biz.Assessme......
  • MongoDB系列之一文总结索引
    概述分类索引的分类:按照索引包含的字段数量,可分为单键索引(单字段索引)和组合索引(联合索引、复合索引)按照索引字段的类型,可以分为主键索引和非主键索引按照索引节点与物理记录的对应方式来分,可以分为聚簇索引和非聚簇索引,其中聚簇索引是指索引节点上直接包含了数据记录,而后者......
  • MongoDB系列之WiredTiger引擎
    概述关系型数据库MySQL有InnoDB存储引擎,存储引擎很大程度上决定着数据库的性能。在MongoDB早期版本中,默认使用MMapV1存储引擎,其索引就是一个B-树(也称B树)。从MongoDB3.0开始引入WiredTiger(以下简称WT)存储引擎,在性能及稳定性上都有明显的提升。从MongoDB3.2开始,WT作为默认的引......
  • 题解:Codeforces Round 967 (Div. 2) B [思维/构造]
    B.GeneratePermutationtimelimitpertest:1.5secondsmemorylimitpertest:256megabytesinput:standardinputoutput:standardoutputThereisanintegersequence\(a\)oflength\(n\),whereeachelementisinitially\(-1\).Misukihastwoty......
  • MAC安装CocoaPods
    如果已经安装过,则先执行卸载gemuninstallcocoapodssudorm-fr~/Library/Caches/CocoaPods/sudorm-fr~/.cocoapods/repos/master/新安装先执行geminstallcocoapods如果报错可尝试使用下面的命令sudogeminstall-n/usr/local/bincocoapods预览版sudogem......
  • Codeforces Round 966 (Div. 3)
    A.PrimaryTask#include<bits/stdc++.h>usingnamespacestd;usingvi=vector<int>;voidsolve(){strings;cin>>s;if(s.size()<=2){cout<<"NO\n";return;}if(s[0]!......
  • 题解:Codeforces Round 967 (Div. 2) [暴力/贪心]
    A.MakeAllEqualtimelimitpertest:1secondmemorylimitpertest:256megabytesinput:standardinputoutput:standardoutputYouaregivenacyclicarray\(a_1,a_2,\ldots,a_n\).Youcanperformthefollowingoperationon\(a\)atmost\(n-......