【leetcode】检测大写字母

bool detectCapitalUse(char * word){
    bool smallFlag=false;
    int cnt=0;
    for(int i=0; i<strlen(word); i++){
        if(word[i]>='A' && word[i]<='Z'){
            cnt++;
            if(smallFlag)
                return false;
        }
        
        if(word[i]>='a' && word[i]<='z'){
            if(cnt>1)
                return false;
            smallFlag=true;
        }          
    }    
    return true;
}
原文地址:https://www.cnblogs.com/ganxiang/p/14012510.html