当前位置:网站首页>Force deduction ----- the number of words in the string
Force deduction ----- the number of words in the string
2022-07-26 13:35:00 【qq_ thirty-seven million seven hundred and sixty thousand seven】

int countSegments(char * s){
int len=strlen(s);
int count=0;
int flag=0;
for(int a=0;a<len;a++){
if(s[a]!=' '){
flag++;
}
else{
if(flag>0){
count++;
}
flag=0;
}
}
if(count==0&&flag==0){
return count;
}
if(s[len-1]==' '){
return count;
}
return count+1;
}
边栏推荐
- Parent class reference to child class (parent class reference points to child class object)
- Precautions for triggering pytest.main() from other files
- File upload and download performance test based on the locust framework
- Photoshop (cc2020) unfinished
- B+ tree index use (6) leftmost principle -- MySQL from entry to proficiency (18)
- Oom caused by improper use of multithreading
- How to remove black edges from hyperimage images (two methods)
- Sword finger offer (x): rectangular coverage
- Brief introduction of reflection mechanism
- 解决远程主机无法连接mysql数据库的问题
猜你喜欢

银行业客户体验管理现状与优化策略分析

Algorithm -- continuous sequence (kotlin)

官宣!艾德韦宣集团与百度希壤达成深度共创合作

Probability theory and mathematical statistics

【花雕动手做】有趣好玩的音乐可视化系列小项目(12)---米管快速节奏灯

How to write the introduction of GIS method journals and papers?

Seven steps to copywriting script ---- document team collaborative management

WPS凭什么拒绝广告?

ROS2学习(1)ROS2简述

3D modeling and rendering based on B é zier curve
随机推荐
Niuke brush sql---2
Comparator (interface between comparable and comparator)
This article explains the FS file module and path module in nodejs in detail
[upper computer tutorial] Application of integrated stepping motor and Delta PLC (as228t) under CANopen communication
JSON format execution plan (6) - MySQL execution plan (52)
力扣------字符串中的单词数
One stroke problem (Chinese postman problem)
MySQL data directory (2) -- table data structure (XXV)
带你熟悉云网络的“电话簿”:DNS
7-25 0-1 backpack (50 points)
Implementation of SAP ABAP daemon
Basic sentence structure of English ----- origin
我们被一个 kong 的性能 bug 折腾了一个通宵
Jenkins 中 shell 脚本执行失败却不自行退出
Brief introduction of reflection mechanism
JSON数据传递参数&日期型参数传递
Detailed explanation of factory mode
Sword finger offer (x): rectangular coverage
Extra (5) - MySQL execution plan (51)
Dimension disaster dimension disaster suspense