C++蒟蒻RE求助!!!!!!

B3843 [GESP202306 三级] 密码合规

wangruize88 @ 2023-12-16 22:14:11

样例都过了,没开O2优化,C++14

#include <stdio.h>
#include <string.h>
#include <string>
using namespace std ;
bool is_hg ( char str[] ) {
    if ( ! ( strlen ( str ) >= 6 && strlen ( str ) <= 12 ) ) return false ;
    for ( int i = 0 ; i < strlen( str ) ; i ++ ) {
        if ( ! ( ( str[i] >= 'a' && str[i] <= 'z' ) || ( str[i] >= 'A' && str[i] <= 'Z' ) || ( str[i] >= '0' && str[i] <= '9' ) || str[i] == '!' || str[i] == '@' || str[i] == '#' || str[i] == '$' ) ) {
            return false ;  
        }
    }
    for ( int i = 0 ; i < strlen( str ) ; i ++ ) {
        if ( str[i] == '!' || str[i] == '@' || str[i] == '#' || str[i] == '$' ) {
            return true ;
        }
    }
    return true ;
}
int main () {
    char str[1000] ;
    do {
        int i = 0 ;
        while ( ( str[i] = getchar () ) != ',' ) i ++ ;
        str[i] = '\0' ;
        if ( is_hg ( str ) == true ) printf ( "%s\n" , str ) ;
    } while ( str[strlen(str)-1] != '\n' ) ;
    return 0 ;
}

by luuia @ 2023-12-16 23:26:36

程序无法正常结束


|