当前位置:网站首页>Statistical words (DAY 101) Huazhong University of Science and Technology postgraduate examination questions
Statistical words (DAY 101) Huazhong University of Science and Technology postgraduate examination questions
2022-08-04 23:39:00 【Zhang Xueheng】
Article table of contents
1: Question
Write a program that reads a line of text input by the user that ends with . , counts how many words there are in total, and outputs how many characters each word contains.(Any part separated by one or more spaces is a word)input formatOne line containing a string ending with . .Note that the last word is immediately followed by a . to indicate the end of the sentence, but the . does not count towards the word.output formatA total of one line, in order to output the number of letters contained in each word in the string.data rangeString length cannot exceed 1000.Input sample:hello how are you.Sample output:5 3 3 3
2: Code Implementation
Keep reading while (cin>> s) str[k++]=s;
Read the input data into an array, complete the process of storage and ++
str[k]=s;
k++;
#include #include #include using namespace std;const int N=1010;string str[N];string s;int main(){int k=0;while(cin>> s)str[k++]=s;for(int i=0;i<k-1;i++)cout << str[i].size()<< '';cout << str[k-1].sizespan>()-1;return 0;}边栏推荐
- 三大技巧让你成功入门3D建模,零基础小白必看
- Nuclei(二)进阶——深入理解workflows、Matchers和Extractors
- Will we still need browsers in the future?(feat. Maple words Maple language)
- Go 语言快速入门指南:什么是 TSL 安全传输层
- 【七夕快乐篇】Nacos是如何实现服务注册功能的?
- .net(C#)获取两个日期间隔的年月日
- 【无标题】线程三连鞭之“线程池”
- [Cultivation of internal skills of memory operation functions] memcpy + memmove + memcmp + memset (4)
- 话题 | 雾计算和边缘计算有什么区别?
- KT148A语音芯片ic工作原理以及芯片的内部架构描述
猜你喜欢

KT148A语音芯片ic工作原理以及芯片的内部架构描述

三大技巧让你成功入门3D建模,零基础小白必看
![[Happy Qixi Festival] How does Nacos realize the service registration function?](/img/df/5793145da45bc80d227b0babfac914.png)
[Happy Qixi Festival] How does Nacos realize the service registration function?

一点点读懂thermal(一)

没有这些「伪需求」,产品经理的 KPI 怎么完成?

365天深度学习训练营-学习线路
![[Cultivation of internal skills of string functions] strcpy + strcat + strcmp (1)](/img/b6/5a1c8b675dc7f67f359c25908403e1.png)
[Cultivation of internal skills of string functions] strcpy + strcat + strcmp (1)

Day118.尚医通:订单列表、详情、支付

未上市就“一举成名”,空间媲美途昂,安全、舒适一个不落

一点点读懂cpufreq(一)
随机推荐
Community Sharing|Tencent Overseas Games builds game security operation capabilities based on JumpServer
如何写好测试用例
Web安全开发 | 青训营笔记
安全软件 Avast 与赛门铁克诺顿 NortonLifeLock 合并案获英国批准,市值暴涨 43%
一点点读懂regulator(四)
jenkins发送邮件系统配置
TypeScript - the use of closure functions
365天深度学习训练营-学习线路
建模师经验分享:模型学习方法
KT148A语音芯片ic工作原理以及芯片的内部架构描述
4 - "PyTorch Deep Learning Practice" - Backpropagation
ClickHouse 二级索引
再肝3天,整理了90个 NumPy 例子,不能不收藏!
OPENCV学习DAY8
深度|医疗行业勒索病毒防治解决方案
web3.js
The role of @Async annotation and how to implement asynchronous listening mechanism
2022年华数杯数学建模
没有这些「伪需求」,产品经理的 KPI 怎么完成?
Xiaohei's leetcode journey: 95. Longest substring with at least K repeating characters