#include <leetcode.h>
◆ countValidWords()
int leetcode::number_of_valid_words_in_a_sentence::Solution::countValidWords |
( |
const string & |
sentence | ) |
|
|
static |
< 有效单词数
< 是否是有效单词
< 是否已经存在连接符'-'
当前字符
在文件 leetcode.cpp 第 1718 行定义.
1719 auto *str =
new char[sentence.length() + 1];
1720 strcpy(str, sentence.c_str());
1722 for(
const char *token = strtok(str,
" "); token !=
nullptr; token = strtok(
nullptr,
" ")) {
1724 bool hyphen =
false;
1725 for(
int i = 0; token[i] !=
'\0'; i++) {
1726 const char ch = token[i];
1735 if(i == 0 || token[i + 1] ==
'\0') {
1740 if(isalpha(token[i - 1]) == 0 || isalpha(token[i + 1]) == 0) {
1745 }
else if(token[i + 1] !=
'\0' && isalpha(ch) == 0) {
1749 }
else if(isdigit(ch) != 0) {
bool is_valid(int year, int month, int day)
引用了 pat::b::b1028::is_valid().
被这些函数引用 leetcode::number_of_valid_words_in_a_sentence::TEST().
该类的文档由以下文件生成: