当前位置:网站首页>Calculates the length of the last word in a string, separated by spaces
Calculates the length of the last word in a string, separated by spaces
2022-06-30 14:05:00 【Fat Xiao Deng】
Title Description :
Calculate the length of the last word in the string , Words are separated by spaces .
Input description :
The input line , Represents the string to be evaluated , Non empty , The length is less than 5000.
Output description :
Output an integer , Represents the length of the last word of the input string .
1| Input
2|hello nowcoder
3| Output
4|8
Positive order ergodic ,count Count letters , Space encountered , Recount .
#include<stdio.h>
#include<string.h>
int main(int argc, char const *argv[])
{
char str[101];
fgets(str,sizeof(str),stdin);
int len,i,count=0;//count For counter
len=strlen(str);
for(i=0;i<len-1;i++)
{
++count;
if(str[i]==' ')// Encountering spaces, count again
{
count=0;
}
}
printf("%d\n",count);
return 0;
}
边栏推荐
- Intelligent operation and maintenance: visual management system based on BIM Technology
- 嵌入式开发:5个可能不再被禁止的C特征
- [kali] Kali system, software update (with image source)
- There is no utf8 option for creating tables in Navicat database.
- 科普达人丨漫画图解什么是eRDMA?
- 发生QQ大规模盗号事件,暴露出什么网络安全问题?
- 随着产业互联网的发展,有关互联网的落地和应用也就变得宽阔了起来
- Paper interpretation (AGC) attributed graph clustering via adaptive graph revolution
- 【科研数据处理】[实践]类别变量频数分析图表、数值变量分布图表与正态性检验(包含对数正态)
- 可觀測,才可靠:雲上自動化運維CloudOps系列沙龍 第一彈
猜你喜欢

Observable, seulement fiable: première bombe de salon de la série cloudops d'exploitation et d'entretien automatisés dans le nuage

逆向调试入门-PE中的VA与RVA换算04/07

A keepalived high availability accident made me learn it again!

Heavyweight: the domestic ide was released, developed by Alibaba, and is completely open source!

Google Earth Engine(GEE)——GHSL:全球人类住区层,建成网格 1975-1990-2000-2015 (P2016) 数据集
![[KALI] KALI系统、软件更新(附带镜像源)](/img/ac/43a3f81d50ab6866271b500b142252.png)
[KALI] KALI系统、软件更新(附带镜像源)

损失函数:DIOU loss手写实现

SQL编程问题,测试用例不通过

This editor will open source soon!

Introduction to two types of rxjs observable operators
随机推荐
华为帐号多端协同,打造美好互联生活
一文讲清楚什么是类型化数组、ArrayBuffer、TypedArray、DataView等概念
Talk about Vue's two terminal diff algorithm, analysis of the rendering principle of the mobile terminal, and whether the database primary key must be self incremented? What scenarios do not suggest s
【Kubernetes系列】K8s设置MySQL8大小写不敏感
Today's sleep quality record 80 points
How does MySQL merge columns?
Simple understanding of the difference between get request and post submission
正则系列之断言Assertions
Basic syntax of unity script (1) - common operations of game objects
我如何才能保护我的私钥?
随着产业互联网的发展,有关互联网的落地和应用也就变得宽阔了起来
Google Earth Engine(GEE)——GHSL:全球人类住区层,建成网格 1975-1990-2000-2015 (P2016) 数据集
Loss function: Diou loss handwriting implementation
SQL attendance statistics monthly report
点击table的td单元格出现dialog弹窗,获取值后将值放回td单元格
Unity Animator 参数
IM即时通讯应用开发中无法解决的“顽疾”
防火墙基础之总部双机热备与分支基础配置
Development of unity script program
Lucky hash quiz system development (source code deployment) fun investment hash game play development (case requirements)