首页 > 学院 > 开发设计 > 正文

leetcode520

2019-11-08 01:19:38
字体:
来源:转载
供稿:网友
class Solution {public: bool allCap(string Word) { int i; for(i=0;i<word.length();i++) { if(word[i]>='a'&&word[i]<='z') break; } if(i==word.length()) return true; else return false; } bool allNotCap(string word) { int i; for(i=0;i<word.length();i++) { if(word[i]>='A'&&word[i]<='Z') break; } if(i==word.length()) return true; else return false; } bool onlyFirstCap(string word) { if(word[0]>='A'&&word[0]<='Z') { int i; for(i=1;i<word.length();i++) { if(word[i]>='A'&&word[i]<='Z') break; } if(i==word.length()) return true; } return false; } bool detectCapitalUse(string word) { if(onlyFirstCap(word)||allCap(word)||allNotCap(word)) return true; else return false; }};
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表