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

题目:

题解:

cpp 复制代码
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);
}
相关推荐
Billlly4 小时前
ABC 453 个人题解
算法·题解·atcoder
weixin_446023565 小时前
C语言:面向过程、应用底层开发、跨平台的通用程序设计语言
c语言·跨平台·数据类型·底层开发·面向过程
无敌昊哥战神6 小时前
深入理解 C 语言:巧妙利用“0地址”手写 offsetof 宏与内存对齐机制
c语言·数据结构·算法
小白菜又菜6 小时前
Leetcode 2075. Decode the Slanted Ciphertext
算法·leetcode·职场和发展
cmpxr_8 小时前
【C】数组名、函数名的特殊
c语言·算法
itman30110 小时前
C语言怎么学?从写程序到玩指针的实操攻略
c语言·指针·结构体·编程学习·资源推荐
摸个小yu10 小时前
【力扣LeetCode热题h100】链表、二叉树
算法·leetcode·链表
kang_jin11 小时前
C语言结构体入门:stu定义与成员使用
c语言·教程·编程语言·入门·结构体
skywalker_1112 小时前
力扣hot100-5(盛最多水的容器),6(三数之和)
算法·leetcode·职场和发展
生信研究猿12 小时前
leetcode 226.翻转二叉树
算法·leetcode·职场和发展