Bootstrap

C语言 | Leetcode C语言题解之第520题检测大写字母

题目:

题解:

bool detectCapitalUse(char * word){
    int len = strlen(word);
    int res = 0;
    int index = -1;
    if(len == 1)
        return true;
    else{
        for(int i = 0; i < len; i++){
            if(isupper(word[i])){
                res++;
                index = i;
            }
        }
    }
    return res == len || res == 0 || (res == 1 && index == 0);
}
;